Flows of energy

by Marijn Haverbeke (license)

Heckle, or how I shall try to blog again

Thursday, September 6, 2012 javascript templating tooling

Last week, the need for a platform to publish my bi-directional text story on forced me to think about blogging software once more.

I had heard that all the cool kids are now using Jekyll on their Github pages to publish their blogs. I am not keen on depending on Github for yet another aspect of my online life, but the idea of generating a static site from a git repository does sound appealing.

Setting up a simple site with Jekyll was a breeze. It really is a well-designed approach. But I also immediately ran into its limitations. Something as simple as sorting my list of tags by the amount of posts they contain was... apparently not possible without monkey-patching some classes from a plug-in.

Now I have all the respect in the world for the Ruby community and their anarchist approach to modularity, but such shenigans just don't fit my own sense of aesthetic. On the other hand, templating languages like Liquid, which Jekyll uses, are not nearly anarchist enough for my taste—they strictly forbid any kind of interesting logic to be placed in the template. I'm sure this is a good thing in some projects with some teams. But having to add code in another, largely unrelated place, just to be able to sort a stupid list in a certain way is not helping.

It turned out that, because of Jekyll's brilliant simplicity, cloning it was easier than figuring out how to monkey-patch it.

Several hours, and two hundred lines of code later, I present to you: Heckle, a node.js-based Jekyll clone.

It obviously doesn't have all the features of Jekyll—only the core things that I needed to generate this site. It converts Markdown files with a YAML front matter to HTML using templates from the _layouts and _includes directories. It finds posts in the _posts directory and understands what tags mean. And it copies all other files in the working directory over to _site, where the output ends up, and which you can then point your web server at.

For templates, Heckle uses a modified version of Mold, which was designed for unrestrainedly mixing JavaScript logic into templates. It was originally designed for client-side instantiation, and I had to fix some limitations that made it work poorly with node.js. Those'll probably soon be integrated in the main repository.

The sources for my new blog are on Github. I imported some old posts to make it look less empty. With luck, I'll actually form a blogging habit this time around.