7 February 2010 · About 5 minutes read

Switching to Jekyll

For several years now, I’ve used Wordpress to power this site. As I’ve learned to use new tools for coding (vim, git and so on), Wordpress has started to seem a little too heavy, especially for just writing posts. A textarea editor just can’t cut it when you’ve been using vim for a couple of years.

So I started looking for alternative blogging engines. After trying out a few Rails-powered engines, I eventually stumbled across Jekyll.

Jekyll is described as a “blog-aware static site generator”, and I set about giving it a try. After a few minutes, I knew that Jekyll was what I’d been looking for. It lets me edit my site in a text editor of my choosing, generates static HTML files (no more heavy server-side tech), and sits perfectly in a Rails-esque git push; rake deploy workflow.

So after a few days migrating from Wordpress, this site is now 100% Jekyll powered: there is no back-end PHP; no database connection to worry about; and everything is versioned and backed-up through git. I’ve used a fork of Jekyll that lets me write templates in Haml rather than stock HTML.

There have been a few bumps along the way, but thanks to the growing Jekyll community and wiki, there are plenty of helpful guides and tricks available to solve any problems I’ve had. Here’s a quick overview of how I’ve switched to Jekyll.

Pure Text

Jekyll uses plain text for everything. Plain text is great - it’s small and portable; can be edited using your editor of choice, and is easily versionable using tools like git.

Deploying

With a suitable Rakefile, managing my site is as simple as writing a post and running rake deploy. Rather that git post-commit hooks, I’ve used rsync (as described in this post) to push files into my server’s blog directory.

Comments

Having no server-side scripting means that Jekyll sites have no way to submit and process comments. The Jekyll sites I’ve seen either don’t use comments, or implement them through a hosted service such as Disqus or IntenseDebate.

I like the conversation that comments bring, so I went with Disqus to manage this site’s comments. The process was fairly simple, and just involved adding a couple of

As an added bonus, using a hosted service lets you keep track of your conversations across the web, and listen for replies across a number of sites more easily.

Migrating Posts

Jekyll comes with a set of converters for getting your posts out of other blog engines. You can find them in the lib/jekyll/converters/ folder of the Jekyll repository.

I had 6 years worth of posts stored in Wordpress, and used the built-in converter to extract them. This was fine, but I found the default converter didn’t migrate tags and categories.

After taking a quick look at the Wordpress database structure, I forked Jekyll and added a snippet of code to pull out each posts’ tags and categories. The tags and categories are inserted into each post’s YAML front matter.

You can find my fork of Jekyll on Github.

Code highlighting

Jekyll uses pygments to as its source highlighting engine. As a lot of my posts include code snippets, I’ve come to rely heavily on the wp-syntax plugin. Jekyll uses a different markup delimiter though, so I’ve not yet managed to migrate highlighted source code. I’m hoping to find some way to patch this, probably using regex. I’ll update my fork of Jekyll with any changes.

An alternative approach that I’m thinking of is to use github gists. This would allow code to be embedded into each post, and would keep all my code in one place.

Google Sitemaps and Pings

My Wordpress site used a plugin to generate a sitemap.xml file every time a post was published. Again, the Jekyll community had already developed a script to replicate this functionality, and my sitemap.xml is now built and submitted to Google every time with every update.

RSS/Atom Feeds

My site’s feed is handled through Feedburner. For the few users that were directly subscribed to my site’s raw XML feed (http://chrisblunt.com/blog/feed), I’ve used Apache mod_rewrite to redirect requests to Feedburner. This should be transparent to those subscribers, but please let me know if you find otherwise.

So that’s my site switched over to Jekyll, and I’m glad to say that everything seems to have gone smoothly. Thanks to the magic of mod_rewrite all previous links should still work.

The only problem so far is that code snippets haven’t migrated properly, so you’ll find that they aren’t syntax highlighted. I’ll work on switching those manually once I decide whether to go with gist or pygments.

There are likely to be a few more tweaks to the site’s layout and theme. I’ll also be posting more as I get to grips with Rails 3 and Android, and Claire and I start on our travels in March…

Chris Blunt
Chris Blunt @cblunt
Chris is the founder of Plymouth Software. As well as code and business, he enjoys being a Dad, swimming, and the fine art of drinking tea.