A first post

A post describing the why and the how of the technical setup of this blog
Published on December 2, 2009 under the tag haskell

A first post describing the technical setup of this blog, for that is what technical blogs usualy do. I started looking around, and these were my best options:

The current setup is really simple. Inspired by my favorite window manager, it uses a Haskell file as main configuration tool. I’ll now explain the system a little by showing some random pieces of code.

main = do
    staticDirectory "images"
    staticDirectory "css"
    staticDirectory "js"

See what I did there? I declared some static directories. These will just be copied directly when I generate the site.

postPaths <- liftM (L.reverse . L.sort) $ getRecursiveContents "posts"

Here, I take all posts paths from the posts directory. I sort them and then I reverse them, so the most recent posts will come first. Now I’m going to render all posts:

sequence (map readPage postPaths) >>=
    mapM (renderAndWrite "templates/default.html")

For those who do not know Haskell, I just read all post pages using a map, and then I mapped the result again, so all posts were written using the templates/default.html template. The templates are very simple, an example could be

  <title> $title </title>

Were all $identifiers get replaced with items from a map. Another cool feature is that the amazing Pandoc library is used for converting and reading posts. This basically means I can write my posts in simple markdown, with additional features like the cool syntax highlighting you can see in this blog post. Some metadata can also be added to the files. This post, for example, starts with

title: A first post
date: December 2, 2009

# A first post

Well, that’s all for now, folks. Maybe I will elaborate on hakyll again later, for some reasons I cannot do that yet (I haven’t tested it enough, and the code is not the best you’ve ever seen). All comments and suggestions are of course welcome!

Your most humble and obedient servant, Jasper Van der Jeugt