You're viewing a post from the archive. Don't forget to checkout our latest post Let them eat State

Since we started this blog it has been running on the same Mephisto release (on Rails 1.2). Aside from being far from easy to upgrade and migrate the data to the latest version of of Mephisto, we were getting pretty bad comment spam and syntax highlighting was frustrating.

Classic blogging apps were never quite up to the job in my opinion. The editing interface is just a textarea or a broken wysiwyg editor and versioning is shoehorned into a database. Since moving our wiki from an app to simply markdown files on Github we haven't looked back, so why not the blog?

The Jekyll is a neat little static site generator which can also help with maintaining a blog. Migrating over required the use of a few scripts. Firstly to dump the old blog posts in Mephisto into markdown files, and secondly for comments. Having a statically generated site also means comments need to be hosted somewhere else. We went with Disqus which provides a pretty good js commenting service, and used a script to migrate the Mephisto comments over there.

I also thought it would be nice to have all the code snippets hosted at gists.github.com, but didn't want to include them all using Javascript, so I wrote a little liquid filter to pull them directly into a page when the site is generated. These tweaks are all in the newbamboo jekyll branch.

Our Jekyll has the following tweaks

  • Date format in urls to match Mephisto so the urls didn't break
  • Some extra lists of posts for use in the templates (our front page has 3 full text posts, followed by 5 titles and finally an archive page with the titles of all posts)
  • date_to_rfc2822 for use in the rss feed

Jekyll

First step is to setup Jekyll locally, which is all covered by the readme in the repo. You'll see that posts are simply .markdown files in the _posts directory, so if you're migrating an old blog you'll need to dump all your data there.

When you run the jekyll command inside your blog's directly it'll then convert all the markdown files in the _posts dir into html, using the little bit of yaml at the top to set the layout and provide variables for the liquid layout (e.g. we have put author in the yaml of all of our articles). If you then put a .html file in the root of your blog dir it will get run through the liquid generator after the posts have been generated, so it has access to the list of all posts etc.. This is how the index.html and archive.html pages are done.

Layouts live in the _layouts dir. Our default.html and post.html layouts were left pretty much untouched from our Mephisto theme.

Migrate articles from Mephisto

The following script is a quick hack to write all of the articles from our old MySQL Mephisto database. It's going to need tweaking if you're going to use it with anything else.

Migrate comments from Mephisto to Disqus

This script was modified a bit from the original. It's a bit of a kludge because Disqus doesn't allow you to delete comments via the API, and they only just added a feature in the admin to remove a site from your account. You may find yourself running this several times before you get that single clean import.

Use Google for search

With no database we need to handle search elsewhere as well. Google does a pretty good job, so we changed our search form to submit to site search, and then setup an nginx redirect (see next section) so any indexed searches would end up in the right place. See the search form in our index.html for how it's done.

Nginx redirects

Nginx is used to serve up the static site. We had to setup a several redirects to indexed pages from the Mephisto days still worked.

The search redirect is pretty interesting and took some fiddling to get right. It takes an old search url like "http://blog.new-bamboo.co.uk/search?q=rails" and redirects it to Google site search with the same query string.