Static Generators

Posted on May 23, 2014

In the early days of the web before we had coined the term, “blog,” I wrote a Perl script that concatenated the contents of textfiles into a set of HTML files. I would then upload the resulting files over FTP to a free community web host. We now have a term for this kind of script: a static generator.

My original script was crude by comparison to the available static generators today. Today we have template languages, stylesheets, and syntax highlighters. My script back then hard-coded everything. I had to change the code if I wanted to change the resulting output. I had to manually format my “posts” in HTML. Markdown wasn’t invented until many, many years later.

It wasn’t flexible. I had to name my text files a certain way. I had to format them a certain way. I wouldn’t be able to just pass my files into someone else’s script and expect it to work. I was just learning Perl at the time and was still just a kid. My program worked for me and it was fun to hack on.

That was more than 14 years ago.

Today we have Markdown. We have template languages. We have stylesheets. We have syntax highlighters. We have more useful tools today than when I started out. And it’s still painful to switch between blog tools.

I started this blog on Wordpress. I was into PHP at the time, it was available on my web host, and I knew its templating language rather well. In recent years I had grown sick of the constant security updates and having to migrate to a new host and manage the stack myself. So I decided to move to a static generator.

I chose Pelican. It had a Wordpress import script out of the box. Except that it didn’t work well. So I forked it, created a patch, and uploaded my new site.

I had been using Pelican for almost a year before I pulled in the upstream master branch into my own repo to check out the latest features. It wouldn’t render my site anymore. I tried switching to an official release. Same.

Well it’s just Markdown… how hard could it be to move to try out a new generator?

After some handy-dandy sed/awk/cut/tr-foo with a little help from my shell (fish, of course) I finally converted my content to a format that Mynt understood. It would have probably been easier to figure out what was causing Pelican to trip on my site. This was, of course, the fourth or fifth generator I had tried today. Each one requires different meta-data and configuration and throws interesting, cryptic errors when things don’t parse as expected.

The problem I have now? Templates. It turns out that there aren’t any designers making themes for mynt. And I am a terrible designer. So expect this site to look defaulty until I figure something out.

Conclusion

Static generators are still a pain in the ass to use if you’re someone who has hundreds of posts to render and content from a previous system. If you’re like me and had written these kinds of scripts in the 90’s you might wonder why it’s still this hard. By far the hardest part was getting my posts out of Wordpress. But it’s still not as easy as it could be switching between different static generators even if they all use Markdown these days. It’s the metadata and configuration that seems to kill you. Try to avoid it. Come back in another 15 or 16 years and we might make it less painful by then.