Maksym Prokopov personal blog
Idea is a something worth sharing

Blogging using Emacs with org-mode and Hugo

17.01.2024

Reading time: 2 min.

I use org-mode extensively with org-roam for keeping my knowledge and journals together and working as my brain dump destination. This blog serves kinda the same purpose, so why not to combine these things under Emacs umbrella?

Blogging from Emacs boils down to two options.

TLDR; Hugo can render org file natively, but support of features is quite limited, or use org as source that rendered to markdown. The latter brings issues of content syncing from origin to end result.

screenshot-org-hugo.png

Write posts as org files

I faced the issue of not being able to render index.org as a section from folder. Apart from this all works. Front matter example is

#+title: My Title
#+date: 2023-01-19
#+slug: my-slug
#+tags[]: howto, emacs, hugo
#+draft: true

Adding properties section in front of org file breaks front matter.

:PROPERTIES:
:ID:       00c94cae-b64a-4cdf-81d1-248b2a42b7b7
:END:
#+title: My Title
#+date: 2023-01-19
#+slug: my-slug
#+tags[]: howto, emacs, hugo
This example not going to work and break date parsing

Export org files to markdown

ox-hugo transforms org file to markdown, which, in turn got natively rendered by Hugo.

But this intruduces another problem of keeping everything in sync AKA having "single source of truth".

What are the benefits of using org files?

These are not many, but significant for me. One of the examples is so called Literate programming. The idea is the same as in jupyter notebook, but right inside your editor.

Literate programming

I can execute code right in the middle of the text.

literate.png
Screenshot
2+2
This is the ruby code
4
Result of execution
(+ 2 2)
Clojure code
4
Evaluation of the Clojure code

References

Using Org Mode in Hugo describes how "native" rendering by Hugo works.

My blogging setup with Emacs and Org Mode · Andrey Listopadov example of blog management using export to markdown technique.

Outro

At the end feel free to mix and match. You can use both formats, just write one post in Org and another in Markdown.