Elektrubadur

Converting Sources of This Blog to Org format

By Björn Lindström in Programming about WWW, Markdown, Org, Hugo, Python and Emacs — 

It looks a bit bad that the last entry here was three years ago and was about how the site generation works, and here is another one on the same topic. However, it's in the interest of making it more enjoyable for me to write more that I've switched from Zola to Hugo in order to be able to keep the sources in Org format.

Here I'll just share the script I made to do the format conversion, in case it's useful for anyone else. Actually, half the reason I'm even writing this entry is that I will need to later on repeat this process for another page I manage, and this way I have the script and some notes for then.

At the same time I've moved the sources from GitLab to Sourcehut.

I won't delve deeper into the reasons for that, but I thought I'd post the Python script I used for the conversion in case it's useful for anyone else. It's not particularly pretty and has special casing for various things that were particular to my Zola theme, so if anyone else were to use it, they would in all likelyhood need to do some changes. I made a few manual fixes in the Org source after the conversion, of things that occurred to rarely to mke it worth automating.

The script does the following:

Then I just needed to go ahead and write a Hugo templates that works with this new content directory. Getting the same general structure of the page as in Zola isn't difficult, as Zola is inspired by Hugo and uses a lot of the same conventions. I didn't have to do much to be able to preserve mostly the same hierarchy of the source files for equivalent output.

If you are curious about the Hugo templates used to render this page, they are in the repository with the sources for this page.

Finally, if you want to use the script I've been talking about, you can download it here: convert.py