Blog, Assemble!

Blog, Assemble!

13-07-2013

It has been a while since I wrote my last blog post, over a year at least. A combination of work, family and the complete submission to the chore of creating content led to nothing more than empty promises for bangline.co.uk.

Tumblr, as great as it is, was just too fiddly to get clear code snippets. I wouldn't touch Wordpress and to be honest I fancied a stab at a simple content managed site I had rolled myself.

I really wanted to create content using Markdown (Github Flavoured). Octopress and Jekyll were obvious choices. However, recently I have been using Grunt heavily and had stumbled across the Assemble project.

If you have ever used Yeoman you will know what Grunt is. It's a build tool for JavaScript. Minification, concatenation, compiling CoffeeScript and Sass and the like.

Assemble uses the wonderful Handlebars templating library (this is the default but you can switch in others). You define layouts, helpers and templates, feed in some data and as the name suggests it assembles the lot into whatever you defined in the Grunt task. It also has strong Markdown helpers built in, a huge win for me.

With all my development pleasures ticked I created the following Grunt task and had a static site generator:

assemble:
  options:
    data: 'src/**/*.{json,yml}'
    partials: 'src/partials/*.hbs'
    helpers: [
            'helper-lib', 
            'src/custom_helpers.js'
        ]
    layout: 'src/layouts/default.hbs'

  index:
    options:.
      flatten: true
    files:.
      "tmp/": [
        'src/index.hbs'
      ]

  posts:
    files: [
      expand: true
      cwd: 'src/posts'
      src: ['*.hbs']
      dest: 'tmp/posts'
    ]

Deployment is done via a rake task which pushes the site to AWS using the Fog gem. I'm none too precious about the code and it is open source (linked in the references).

The site is very much "mobile first" in terms of layout and I went with Zurb's Foundation framework. I really just wanted to try something different from Bootstrap and found myself quite productive using Foundation. By no means am I a designer but it's defaults are sensible and I found the base typography really readable on all screen sizes.

I'm interested in any feedback so please hit me up on twitter if you have anything good or bad to say about it.

References