Jeff Mesnil
Weblog · About

I Am Awestructed

August 2, 2012

Did you notice something different on my Web site or my Atom feed?
You shouldn't as I have successfully migrated from Jekyll to Awestruct.

A few months ago, I switched my Weblog from Wordpress to Jekyll because I wanted to have a simpler, slimmer publishing system that could generate a static Web site and be simple to customize. At first, Jekyll fit the bill nicely but as I was starting to tweak it, I was slowed down by its lack of documentation and customization. I want to be able to extend my publishing system, not fork it.

Searching for an alternative, I looked at Awestruct, written by my Red Hat colleague, Bob McWhirter, and liked it. It is an evolution from Jekyll with a nice extensible architecture and good documentation.

As an example of Awestruct extensibility, I wrote an extension to provide an Archive page for my Weblog. Awestruct defines an extension to create a weblog from a single directory with files matching the format of YYYY-MM-DD-post-title (like Jekyll does): do
  extension '/weblog', :posts

I wanted to add a page which lists all my posts sorted by ear and month. I added an extension to Awestruct pipeline for this: do
  extension '/weblog', :posts
  extension '/weblog/archive', :posts, :archive

This extension takes the :posts that were added to the site by the Posts extension, sort them in a hierarchy of year / month / posts and put them in the variable named :archive that can be used inside the template file /weblog/archive (source code).

I could then have a very simple Haml template to display the archive:

layout: page
title : Archive

- site.archive.each do |year, monthly_archive|
  %h2= year
  - monthly_archive.each do |month, posts|  
    %h3= month
      - posts.each do |post|
          = "#{'%d %B %Y')} »"
          - if
  { :href=>post.url }= "#{} #{ post.title}"
          - else
            %a{ :href=>post.url }= post.title

Et voila the result!

In similar fashion, I have been able to add a Daring Fireball-style linked list to my Web site and Atom feed by simply adding a link metadata to the file front-matter and a few lines of HAM to process it.