Taking the advice from the Pragmatic Programmer I set out to learn Haskell this year. My plan didn’t turn out like I expected. I started learning Haskell by working through Real World Haskell. It was tough going, so I decided I wanted to start blogging about it. It was than that I remembered that my blog has been neglegled for a long time (more than a year and maybe 2) and that I had been on the lookout for a different blogging platform for some time.
I had recently found jekyll (a static site generator written in Ruby) from a reference on HN and thought it was a great idea. This is exactly the kind of thing I was looking for. But using jekyll didn’t feel quite (well, sortof– the layout and some of the styling does come from jekyll) right since I had often told myself that I wanted to write my own blogging tool. So I dropped learning Haskell (for the moment) and set out to write my own blogging tool.
My background is mostly in Perl, PHP, and little bit of Ruby. But over the last year I’ve been creating a few tools in Python for automating some day-to-day operations at work. I chose Python at work after reading Why Python? and having similar experiences. The small scripts I would write often worked right out of the editor. I also appreciated how readable the code was. So I started hacking away at a blogging tool using Python.
- mako templates for python-based template generation
- pygments syntax highlighting (via markdown)
- markdown for text-to-html generation
- a local http server for site previewing
To get started, you will need the following:
- Pygments for syntax highlighting. Also see the codehighlight markdown plugin.
- PyRSS2Gen for RSS feed generation
- PyYAML for documents
Posts are contained in the “posts” directory. Each post consists of a YAML preamble that includes the template type and the post title. Post files themselves follow the format YYYYMMDD-post-slug-goes-here.markdown. The year, month, day, and slug will be parsed out of the file name to produce a url of the form /archives/YYYY/MM/DD/slug.html. The preamble looks something like this.
Everything after the close of the YAML preamble (…) is treated as the document contents in markdown. The layout value will be used to lookup the proper template in the “templates” directory and the title value will be plugged into the template to generate the title of the page. At the top level you will also find a “images” and “css” directories containing the expected collateral.
And finally, to render your posts and any other files, run furthermore:
This will process all of your posts using the current directory as the base (where to find css, images, posts, and templates directories), while outputting the rendered content to www. It will also run index.html through mako and startup a local webserver so you can preview the site. To see all of the options provided, run furthermore with -h.
If you get stuck take a look at the usage document I’m putting together. I’m still updating, but it should have enough to get the idea and get started if you want to use it.