TopHome
<2020-05-29 Fri>techemacslispmeta

A note on the new blogging software

In case you were wondering how this blog platform is setup, here is the run down.

Obviously, I spent some time scoping out the existing options available. I wanted this system to be powered by org-mode and there are a bunch of tools1 in this space.

o-blog2 did pretty much exactly what I wanted, but unfortunately it's in an unusable state.

The entirity of this blog is written and managed as a single Org3 file. This is the secret, a single file makes management of content so much simpler. I just open my blog.org and enter stuff in.

The software that converts this org file into the html tree is, you guessed it, entirely bespoke elisp, around 130 lines as of this writing. Think of this as my own custom static site generator.

This generator does 3 things:

  1. Export all 3rd level entries into individual html files. Each heading becomes a post.
  2. Parse through Orgmode tags and generate out index files, one per tag.
  3. Create a top level main page that links to the tag indices and points to the latest 10 posts.

Note: In case you were wondering, the top 2 heading levels are used to group posts into year and month. This is generated as a folder hierarchy, as is evidenced by the url of the posts. While they are year and month for now, they could be anything. The actual timestamp in the posts are taken from org-schedule under each heading. Categorization is entirely managed by tags.

Add a little bit of styling4 to spruce up the individual pages. Now, press a single button, eh, call a single function, (cg/blog-export) and voila!

The generator code is here: https://github.com/ChanderG/dotfiles/blob/master/emacs.org#single-org-file-blog-generator. I suspect it will continue to grow over time, but this place should be the permanent home for this generator, unless it gets too unweildly.

The options used in the source org file are:

#+OPTIONS: html-postamble:nil toc:nil timestamp:nil

Orgmode does all the heavy lifting, from exporting individual posts to providing me easy access to entry data like tags and date of the post. For eg, there are no predefined tags. I can just up and create new tags on the fly and the code will generate new tag index pages. The power of Emacs, ladies and gentlemen.

Footnotes:

4

There is a host of good css styling availble for org html export, all usable with a single line added to your org file. The one being used here is: https://gongzhitaao.org/orgcss