Two Wrongs

Statically Generated Blog

Statically Generated Blog

As of a few hours ago, I have hopefully migrated this blog over from dynamic to static generation smoothly enough that nobody should notice.

Yesterday, when you visited one of the articles on this blog, the server gave a kick to a Haskell program, which went to a database, extracted the article content, and then rendered it in an HTML document for you. Now, when you refresh this page, the server just throws a pre-rendered HTML document at you.

Background

When I set this blog up, I was torn. I really wanted to generate it statically (think Jekyll) because I've had a lot of success with that previously and it's a really convenient approach to blogging.

On the other hand, part of the reason I set the blog up was because I wanted to get some practise at dynamic generation of content. I wanted to learn Yesod which has powered the site for the year (almost) it's been up. When I started this blog a little more than a year ago, I had just gotten a Django web development job, so learning Yesod would be an interesting contrast to Django.

However, I don't have the time to dive deeply into things anymore. I wish I did, but there's a lot more going on in my life. So sadly, the site being powered by Yesod has held it back. Not because Yesod is bad – it's still the best web framework I've tried – but because I'm unfamiliar with it.

A friend of mine switched their blog over to static generation recently, which was the final push I needed.

Effort

The last couple nights I've been hammering out some Haskell code for parsing (easy! I've done that a million times before), file handling (slightly harder until I cheated and installed turtle to do the heavy lifting – turtle is amazing), and HTML generation (very hard because I've basically never done it in Haskell other than in a very small capacity.)

Anyway, creating stuff for this blog has become a lot easier. Previously I typed the posts up in Vim, copied them and pasted them over to the editor on the site, then clicked a bunch of buttons to jump between preview and editor until the post looked decent. Now I can just type in Vim, periodically run a command* and refresh my browser to see what it looks like. Much better.

Tech

Putting work into the technology underneath should be easier too. Things I've feared, like pagination, are just a couple of lines of Haskell away. Same thing with tags and other goodies I've been holding off of because I wouldn't know how to integrate them with Yesod in a good way.

The technology choices that went into this statically generating script/program might be interesting, and I hope to be able to write a bit more about that later. As I mentioned, I use turtle to manage files. I parse stuff with Attoparsec (my go-to parser combinator library these days) and I picked Heist for my templating needs. Heist brought me a lot of headache to start with, but I'm slowly understanding the concepts beneath it and I do like it after all.

Either way, I need to sleep … right now, would be good.