Migrating Blogger posts to Jekyll

23 Aug 2010

When I first launched the Music Library Management blog I made the newbie mistake of using a free Blogger account. Blogger's a great, easy and free (as in beer) service but there are a number of downsides to running a blog on free blogging services. I thought Dharmesh Shah's list compelling, and so I decided to migrate. The question was: what technology or blogging platform should I use?

I'd been using Jekyll to generate the bliss website for a while. There has never been a need for a full database backed website for bliss. To my mind, there are a number of costs with using database backed websites:

  • Financial. Hosting with access to a database, SQL or not, tends to be more expensive than plain HTML file hosting.
  • Complexity. Writing data access code is (a little) more difficult that the alternative. Typically, you have to at least select an appropriate programming language to query and provide data for rendering.
  • Availability and reliability. There's more stuff to go wrong.
  • Portability. The programming language you choose and, depending on how you design it, the database you use will restrict which Web hosts you can select.

These disadvantages to going "fully dynamic" with a database backed website mean that for simple websites with a straightforward publishing workflow a static site generator like Jekyll can make sense.

So I decided to stick with Jekyll. But how to migrate my existing sixty blog posts from Blogger into my new site? Rather than do it manually I hacked a Ruby script together to do the work. It takes in a Blogger export XML script as input, and creates Jekyll blog post files as output. Disclaimer: I have next to zero experience of Ruby programming other than doing-what-needs-to-be-done-when-the-occasion-requires-it. I quite enjoy Ruby, but I'm not even competent at it, let alone any kind of expert.

Here's the script (download it here):

Instructions

  1. Download your Blogger XML export.
  2. Change "path-to-your-export.xml" to be the, err, path to your Blogger export
  3. Change "path-to-your-jekyll-site" to be the, errrr, path to your Jekyll site source on your local hard disk
  4. Change "blog-post" (line 25) to be whatever Jekyll template you want your blog posts to use

Then run it:

ruby importer.rb

Please note: the script also imports the comments and a lot of meta data from your Blogger XML export. You can either clean this up after the script has run, or clean the XML export before running the script (I did the latter, after all: garbage-in, garbage-out).

The YAML front matter for timestamp, tags, name and title will be generated. Hope someone finds this useful! Use the comments below or shoot me an email if you have questions.

blog comments powered by Disqus