Blogging with Org Mode

Blogging with Org Mode, Hugo & ox-hugo

For Ash

Figure 1: It’s this post in org mode inside emacs!

Figure 1: It’s this post in org mode inside emacs!

I use emacs for everything. From writing code, to managing my todos, to writing technical documentation, to reading rss feeds, the little editor that could is a monument to the idea that simple composable elements enable astoundingly complex interactions. So when I heard you could blog using org mode files I was interested.

I have owned the website adamfallon.com for a good few years now. I think it is important to have a web presence that you own, not beholdant to big tech companies.

A few years ago I started moving everything to emacs, and specifically org mode. By using org mode I have plain text, that is easily convertable to other formats via Org exporter (built-in) and pandoc. I can convert org to almost every popular file format (html, pdf, docx, markdown). I frequently write documents in org mode for work, and later convert it for consumption by other users.

I have tried a few technologies over the years to blog with, Jekyll, Gatsby, Wordpress & Ghost. All are good in their own ways, but I found editing in the their bundled editors frustrating and slow compared to the speed and comfort of emacs. So I started looking for solutions to this. I found that it was possible to create a hugo. My current workflow with hugo is as such;

  • Write a blog post in a .org file
  • Add some front matter, which lets the package, ox-hugo know how and where to output my file.
#+hugo_base_dir: ~/Dropbox/adamfallon.com/
#+hugo_weight: auto
#+hugo_auto_set_lastmod: t

<Content>
  • Hit Ctrl+C, Ctrl-E, H, A which exports the current file to mysite/content/docs/
  • Run hugo
  • Run rsync to push the public folder to my server.
  • And voila, my new post is published.

This post is written entirely in org mode, exported to markdown with ox-hugo and then converted to html by hugo.

The process involves a lot of moving parts, but the workflow is simple thanks to emacs and it’s wonderful environment.