Nanoc + Haml + Vlad = heaven

Sorry for the acronym soup, but part of my job is research and development of new website building techniques. I have found a neat and fast way of maintaining websites in the nanoc + haml + vlad combo.
nanoc is a tool that runs on my local computer and compiles small Ruby documents into static web pages, ready for uploading to my web host. What’s so neat about it? It separates a website into content and meta-data. The meta-data is structured like an array. This is fairly technical, but once setup I rarely need to touch it again. The content is just the text in the page; basically just a .txt file that any moron (such as me) could maintain.

For simple sites, this really beats having to maintain entire .html files. The content files really are simple text documents, no html noise. When I am done editing these text files, I press a button and they are compiled into complete html documents with all the HEAD, META, BODY and whathaveyou goodness. I can FTP that over and the site is live, boom!

Markup haiku

Now of course when I say text document, that is almost the case. Being a web geek I do want some structure in there: bulleted lists, headers, a table maybe. To represent structure in simple text files most people choose Markdown. This works quite well. You create html bulleted lists by slapping asterisks in your text file. For reasons of sheer R&D I decided to go with haml.

Haml takes your gross, ugly templates and replaces them with veritable Haiku. Haml is the next step in generating views in your Rails application. Haml is a refreshing take that is meant to free us from the shitty templating languages we have gotten used to. Haml is based on one primary principle. Markup should be beautiful.

I have used haml on a project before and thought it was very neat. It basically is a wet dream for the prototypical detail-obsessed, dont-repeat-yourself meta-code-generating geek. Anywho. Haml enables me to express structure like headings and tables in a still very readable text file. So boom, haml was in.

Get that puppy on the server

Now for deploying a website to the server: I get sick to my stomach doing that by hand. It really is not a job you want to be doing by hand. You might upload to a wrong folder, your upload might fail, you cannot roll back easily, and what about your visitors? Do you want them to see a site that’s half-updated? So in the Rails world we use Capistrano and it works really well. In this case I felt the need to use Vlad the Deployer for this task. It’s Capistrano without all the obesity. And what do you know, it actually works. And it’s fast. Fast is good when deploying.

So now when I am done with my markup haiku, I type svn commit followed by rake vlad:update and just seconds later the updated website is live. And if I make a mistake I can revert back in under a second. Gotta love it.

Ps. I did all this just to maintain a minuscule corporate website. But the fun really was in discovering those new tools.