10 October 2013

A while back I decided I wanted a personal website and a blog, so that I could write out my thoughts as I have them. Once I had a website that was functional enough to serve a blog, I had to figure out how I was going to manage the content. My first instinct was to put all the content in a database, but that had some problems.

First, I would have to be able to update the database. While that's not prohibitively hard, it adds quite a bit of complexity. I'd want to be able to view blog posts locally before pushing them to the entire world. That either means I need to keep the local and production databases in sync or I'd have to have some way of pushing changes from one to the other. Then assuming that I'm going to push changes to the remote database, I'm going to need some way to authenticate myself, since I clearly don't want anyone to be able to post on my blog. I had several thoughts about how to authenticate myself. One appealing one was to somehow prove that I had access to my personal email, and allow access to anyone who can do that. But boy, that'd be quite a bit of work to implement.

Then I had the idea of using a public key protocol to prove my identity. Again, implementing this in my website would be a nightmare, but I already had software that authenticated me via public key: git. All I have to do is put my blog content somewhere in the same git repository I use for source code, and pushes all have to be authenticated. So then I had to decide what form my content would take.

I am using BlazeHtml to do templating, and I considered just making blog posts just another template. However, there's a decent chunk of overhead to adding basic HTML elements with Blaze, and all the content would need to be inside of string literals, which makes it annoying to break up the (presumably) long content onto multiple lines. In the spirit of minimizing both setup time and overhead, I decided to go with Markdown for which there is already a Haskell package. The metadata for a post (its title, date, publication status, and so on) just goes directly into my Haskell source, since I'm making a commit for each blog post anyway.

At the end of the day, this means that I have a blog system where I can view posts locally before publish them on the web, ensure that all posts are actually from me, and write posts efficiently, all without having to manage a database.