freeston.me

I wrote myself a static site generator

The Story

I replaced a perfectly fine static-site generator with a custom one. I had been wanting to make some modifications to my site and whilst it was absolutely possible to do so previously, I never felt particularly inclined to do it. I don't love writing HTML, even less so writing django-style templates. I much prefer working with something like hiccup. I guess I'm easily influenced because a blog post by an author I've never come across before planted the seed.

I was always going to stick with Clojure and had been intending to look into Babashka, a subset of Clojure with precompiled built-in libraries intended for scripting. I recently saw that Michiel Borkent, the author of Babashka, had used it to replace his previous Octopress blog. I thought I'd see if I could do something similar, keeping open the option of switching back to Clojure if things didn't work out.

Babashka comes with a bunch of useful libraries built-in, but it doesn't include any markdown parsing. It does provide a mechanism for other utilities to expose their functionality as Clojure namespaces. I initially attempted to use one called bootleg. Whilst it uses the same markdown parser my site was using, it didn't expose the footnotes option that my existing posts rely on. I opened a PR addressing the issue, but the library isn't actively maintained and I'm still not sure if or when I'll get a reply 1.

Raising the issue, however, prompted Michiel to wonder whether Babashka could run markdown-clj directly from source. Amazingly, although there were a couple of minor issues stopping it from working initially, within less than day he had fixed the issues, got them merged in upstream and had written all about it! I now had all the tools I needed to recreate my site.

The Outcome

At the time of writing, the code for the site now consists of:

I replicated the layout and design of my site almost exactly. I kept the same CSS files and the hiccup templates are equivalent to the original ones. I used my new found custom-code-freedom to make a new home page, rather than just display the latest post as it previously did. My intention is to now expand on this and find better ways to share some of my work than just via blog posts.

  1. This isn't a complaint or a criticism - I don't think we're owed anything from free software maintainers, especially so when they're small one-person projects they created to scratch their own itch.