A new stack (or, many hippo returns)

12 Nov 2014

Missed me?

No, me neither, until the other day when I realised my losing a debit card on holiday had inadvertently stopped payments to my hosting company and downed this site... so I've been offline for a while. As you can see I'm now back to normal... but a lot has changed under the hood.

My blog used to be wordpress driven and resided for several years on a bog-standard LAMP hosting service. Then I relegated the blog to old.wheresrhys.co.uk and set up this one as a jekyll driven github pages site (using some hacky DNS settings to keep both sites under the wheresrhys domain). The death of my LAMP hosting and a quality I have which can best be described as lazy-sightedness* has pushed me to finally bring my hosting infrastructure in line with what I'm accustomed to at work; CI, deploy scripts, node servers and hurrah for heroku.

But there's an elephant in the room. I call that elephant 'Ruby'. Lots of people love Ruby, including the local Rhinoceros, 'Jekyll', but I really can't be bothered with her. I have a pet hippo called 'nodejs' I much prefer hanging out with, even though he and Jekyll don't get on very well. What to do??

A while back I looked for an alternative to Jekyll that ran on node. At the time it wasn't very fertile ground, but it's testament to the dynamism of the nodejs community that the number of options has exploded. Reading through the available tools one of them really caught my eye: Metalsmith. I've recently worked a lot with express and gulp, and in metalsmith there appeared to be a static site generator with a very similar pipe and middleware approach, less dependency ridden and more customisable than I'd imagined I'd find. Too good to be true? Was I getting rid of one elephant only to replace it with another, whiter one?

Having now finished the migration, I'm really happy with metalsmith. It's an excellent, highly customisable tool that, unlike Jekyll, isn't particularly opinionated about how I organise my code.

I have very little insight to share on adopting metalsmith, but would advise against using ui plugins. A few judiciously selected low-level plugins - collections, each and permalinks to name a few - give you enough access to global and per-page metadata to be able to build your own menus and so forth. Building your own will also make it easier to customise to your exact needs.

I'd also stay away from the recipes in metalsmith's documentation as at least some appear to be out of date, and tracking down the cause of a bug when you're including a number of plugins all at once can be difficult. What I found to be far more useful was following this quickstart for a very basic site and then gradually adapting and adding complexity, one feature at a time.

One plugin which deserves special mention is gulpsmith, which allows you to use metalsmith as part of your gulp build (or conversely, to use gulp plugins as part of your metalsmith build). Even though I'm relatively new to gulp I found it more convenient and intuitive to define gulp tasks for each file type/directory (e.g. browerifying js, compiling sass) than to use the equivalent metalsmith plugins and either branch the main metalsmith pipe or do pattern-matching on each file.

And finally, I'm using haikro, a very useful new tool (for which I'm only the second customer) for deploying a node site to heroku without the need to run the build on heroku or commit my built files. It's designed primarily to fit into a ci pipeline which has already built the site once, but is also very handily provides a minimal deployment process very much befitting a simple static site.

And yes, my hippo is very happy with the result.

*always seeking the lazy option, but either not paying enough attention or lacking the insight to identify it