Xah Lee asked me to write about my blog publishing process and how an article gets from Emacs to my site. I've written about most of the parts of the process in various posts but it might be useful to tie everything together in a single post for the benefit of any Emacs users who want to start a blog.
I write my posts with Org-mode in Emacs. As the Org Manual puts it,
“Org-mode contains an HTML (XHTML 1.0 strict) exporter with extensive
HTML formatting, in ways similar to John Gruber's markdown language,
but with additional support for tables.”
The Org-mode markup language makes it easy to insert formatting—such as bold, italics, and code—and hyperlinks to other documents. Even someone with no knowledge of HTML could produce very nice Web pages.
During the writing of the post, and afterward as a final check, I can send it to my browser to see what it will look like. That won't be exactly what you see on Irreal, of course, because I'm really just exporting the post to HTML and displaying in my browser without the benefit of the WordPress style sheet.
As I explain below, it's possible to write a post, export it to HTML, and then paste it directly into your site's editing window but I have a (much) better way. Once I'm satisfied with the post I export it directly to my site using org2blog. Making one call to
org2blog takes care of everything in a single step:
- The post is converted to HTML
- The HTML is uploaded to the WordPress process on my site
- Any pictures or other images in the post are uploaded to the site and their links are adjusted to point to the site's machine rather than my workstation
- The date and Post ID are added to the Emacs buffer containing the post
- Information about the post is recorded in
.org2blog.orgso that any updates to the post will result in the original post being updated rather than a new post being added.
By doing all these things,
org2blog takes care of the majority of the bookkeeping chores associated with making a post.
org2blog finishes with the upload, I save the file again (to save the date and Post ID that
org2blog added), and call Magit to put it in Git. Then I call
dired for my blog directory, type 【* .】
html to mark any HTML files and then 【D】 to delete the HTML files and any associated buffers. At this point, I'm done. The post has been published, the source for it filed away in Git, and extraneous files and buffers have been deleted.
My old blog, also called Irreal, was hosted on Blogger. Although there is a version of org2blog (by a different author) for Blogger I didn't use it. Instead, I used this function
(defun blog-post () "Export an org buffer as HTML but only export the body." (interactive) (org-export-as-html 3 nil nil "*blog-post*" t))
to convert the post to HTML and export the body. Then I would copy the
*blog-post* buffer to the clipboard and paste it into Blogger's HTML editor. That worked fairly painlessly unless there was an image involved. Blogger stores the images in Picasa instead of with the post so doing things by hand can be a bit involved. I wrote about that here. I don't know if the Blogger version of
org2blog handles pictures automatically but if it did, that would be reason enough to use it. If it is anywhere close to as convenient as the WordPress version it would be worth using. If you use
org2blog on Blogger, leave a comment telling us about your experiences with it.