From Wordpress to Jekyll and a new design

Static site compilers have become quite popular in some circles in the past couple of years, especially since the rise of services like Disqus. I decided to make the switch from Wordpress to Jekyll, a "simple, blog aware, static site generator" written in Ruby, for the usual reasons: I got tired of keeping up with Wordpress security updates, and static files give me a warm, fuzzy feeling.

I can now host my site anywhere without ever having to worry about security or server load. Also, being a unix guy who pretty much lives in the terminal, having every post as a plain text file (with Markdown markup) and writing posts in Vim feels great. This also makes it easy to put the site in a Git repository or similar for version control.

Of course, with static files all the way, you need to use something like Disqus if you still want a comment system. Disqus is embedded with JavaScript. I'm not entirely happy with this solution. I prefer being in total control of my own site, and I don't like that JavaScript is required just to read the comments and I don't like the implications it has for archiving. Finding an alternative solution is on my todo list.

I initially played with nanoc, a much more sophisticated Ruby site compiler. However, being lazy, I found that Jekyll was easier to get started with and that I didn't really need the extra power of nanoc. (I will however use nanoc for other projects. It's a really neat piece of software.)

Getting started

Loads of people have their blogs on public GitHub repositories. There's also a long list of Jekyll sites on the Jekyll wiki; many of them have sources available. I started with Tom Preston-Werner's Jekyll site and modified it heavily.

Migrating posts from Wordpress

I imported all my Wordpress posts using the simple technique on the Jekyll blog migrations wiki page ("Using Jekyll + Mysql server connection"). I didn't care about tags, as I was going to redo them anyway. Here is a more advanced import script.

As for images, I just copied wp-content from my Wordpress installation to to the root directory of the new site. I then deleted in wp-content except wp-content/uploads.

To maintain the exact same post URLs I put this in _config.yml:

permalink: /:year/:month/:day/:title

Disqus

I think the easiest way to get all Wordpress comments into Disqus is to install the Disqus Wordpress plugin. (Be sure to sign up for Disqus first.) Then just import all existing comments to Disqus from the plugin's admin page. Voila. Finally, just grab Disqus' "universal code" and place it in _layouts/post.html (or whereever your posts layout file is).

Syntax highlighting

For syntax highlighting I installed Pygments and generated the CSS:

$ pygmentize -f html -S default > css/highlight.css

Pygment comes with a bunch of different styles; run pygmentize -L to list them. I settled on murphy.

One minor gotcha: PHP code didn't get highlighted unless it started with <?php. Turns out you have to add startinline to the highlight options to get around that, like so: {% highlight php startinline %} (end with {% endhighlight %}).

Tags

For tags/categories, I use generate_categories.rb from here.

New design!

I decided to completely change the design while I was at it. I didn't realize until now how lacking the old one was. I'm still playing around with colors. If you see encounter any broken links or something that looks good, give me a shout.

2011-06-04

blog comments powered by Disqus