How I Blog (This Week)

Posted October 2016

I've long used Jekyll to assemble my blog, and Emacs two write all my content and templates. I've been wanting to use jekyll-org to write my blog entries directly in Org format, but that is unfortunately not possible yet, in the way I want it to work. However, I have found a work-around I am happy with for now.

Recently I've started exploring Org-mode's Capture templates, and I've now set up a new template for capturing the outline of a blog post. The template is called tpl-blog-post.org and lives in my ~/org folder. It looks like this:

* NEXT %^{Title}
  :PROPERTIES:
  :EXPORT_FILE_NAME: ~/play/superloopy.io/_posts/%<%Y-%m-%d>-draft-blog-post
  :END:
#+OPTIONS: toc:nil
#+BEGIN_HTML
---
title: %\1
layout: post
abstract: %^{Abstract}
tags: %^{Tags (comma separated)}
---
#+END_HTML

%\2

%?

In my Emacs config I add an entry like this:

(add-to-list 'org-capture-templates
             '("b" "Blog Post" entry (file+headline "Agenda.org" "Blog")
               (file "tpl-blog-post.org") :empty-lines-before 1))

This means I can hit C-c c b and a buffer opens up prompting me for Title, Abstract and Tags, and have these inserted into a new entry. I can then type a rough draft of my post. Hitting C-c C-c saves the draft to my Agenda.org file under the Blog heading.

When I've had a chance to review the nascent blog post I can export it to HTML, from the Org Export Dispatcher: C-c C-e. I have to remember to select Body only by hitting C-b and usually Export scope: Subtree by hitting C-s, before I export to HTML with h h. Because of the EXPORT_FILE_NAME property, Org puts the exported file directly into my Jekyll _posts directory, where it will be picked up.

Because I end up checking in HTML source, rather than Org source it is not entirely ideal if I then need to go back editing blog posts. But in my experience I don't do that a lot. And if I do then I should be able to find my old source in my ~/org/Archive.org file, where most deleted from ~/org/Agenda.org ends up. This directory is in iCloud Drive.