A new way to blog

If you’ve ever visited my website before, you’ll probably notice that the template has changed once again. But that’s not all – some major changes have also been made under the hood…

My website/blog-that-I-don’t-write-on-very-often is now powered by nanoc, a static site generator. What this means is that nothing dynamic happens when you load a new page – it’s all been generated beforehand. I already had experience using nanoc with the website for my “brand name for freeware projects”, rojekti, so this wasn’t a very difficult process.

There wasn’t anything wrong with my previous blogging softawre, WordPress – I just find nanoc more comfortable to use, and writing is much easier to do in vim instead of a WYSIWYG editor.

In any case, here’s a small outlining of the steps involved.

Creating the new layout

Some experimenting with gradients and color schemes in Photoshop, and a couple of hours to write the markup and stylesheet.

Nothing special here.

Creating the nanoc website

But this is where things get interesting. First off, I adapt the new website layout to the nanoc project, and I enable and configure some things like the blogging helper.

But what’s a blog without posts? I obviously want to have the old posts I had on the WordPress installation to be on the website.

Well, in the one and a half years I’ve had this blog I haven’t written that much, so I “migrated” new posts completely by hand. This was a good idea in any case, because it gave me the opportunity to rewrite the posts in Textile).

And once I’m done, I add an Atom feed and a sitemap file for crawlers. I make the front page display the latest 5 posts and the rest in a simple list: I’ll have to look at generating real pagination later.

But what about comments?

Of course, when your blog is statically generated, a dynamic commenting system might be rather difficult to implement. Fortunately, there are services to provide commenting for websites.

One of them is Disqus. Many WordPress/Blogger/whatever users actually use it instead of their built-in comment systems because it’s better.

And best of all, Disqus can be embedded to any page using a few lines of JavaScript – so that was easy!

…But what about the existing comments?

Not that my blog has ever been a very popular internet destination, but there are some useful comments on the posts I’ve made. So how do I migrate them into Disqus?

Disqus provides an API. It has a function to create new comments. And to make things even easier, someone’s made a Ruby wrapper for the API!

So I export comments using phpMyAdmin to CSV, and write a quick Ruby script to read them in and send them to Disqus. Easy!

What else?

I really like the “new workflow” of writing posts – it could actually inspire me to write more often. A major problem I had with WordPress was the WYSIWYG editor: it’s just painful to use. This is obviously a problem common to any publishing application.

I already mentioned this before, but by default nanoc processes my blog posts as Textile). Textile is a simple markup language designed exactly for the purpose. And if I never need HTML, mixing it with Textile is very easy.

Using a static site generator feels just right to me, but having to execute nanoc create_item posts/hello-world might not be fit for everyone. And that’s exactly why software like WordPress exists. Use the right tool for the job!

Oh, and one last thing – I also version the blog using git. A great example of how versatile modern DVCS’s can be.

Leave a Reply