New Blog!

Well, a new life for the old one, anyway. Ahem. So, it has been a while I believe? Sorry about that!

In the last, err, over a year since last posting I have, at least:

Unfortunately the weather wasn’t great for photos in Nepal this time, so there’s probably only one post there. I don’t have many great pictures from South America either, but I can probably manage to eke out a few more posts!

In the mean time though, I migrated this blog. It spent the first couple of years of its life on posterous, which was a great platform at the time but more recently seemed a bit neglected while the team cast around for ways to keep it alive before accepting a pity-acquisition from Twitter. I decided to move it to a new platform — the rest of this gets a bit nerdy, sorry!

Jekyll-bootstrap, github-pages, and the migration process

I decided to move to a static-site option, giving me a bit more flexibility as well as control over my data: in other words, all of the site is generated once per post, then served as simple files rather than from a database. I also wanted to be able to keep it in git, although that’s almost a given with most site-generator options.

There’s plenty of options for site generation, but one of the most popular alternatives is jekyll. By itself this only offers a flexible but bare site generation framework; jekyll-bootstrap adds a framework tailored for blogging on top, along with themes based on the now-ubiquitous Twitter-bootstrap. I also looked pretty hard at Octopress, again based on jekyll, but made a slightly-arbitrary decision to go with jekyll-bootstrap (Hyde deserves mention too, including because it’s built on technologies I’m more familiar with). I think this decision was at least in part due to the greater integration with github — see below — although in reality this is almost a non-issue.

For those of you who don’t know, github offers a static site hosting service, including custom domain names if you wish. All that’s needed is a specially-named repository, and they will serve it as a website for you. As a bonus, they also have jekyll integration and can generate your site for you (of course, otherwise you just generate it yourself before pushing to git-hub, which is what I ended up doing. If at any time github becomes less suitable I can easily host the files myself, or use Amazon S3, or any other alternative.

Firstly though, I wanted to take all my previous content with me. This wasn’t too challenging, but did involve a couple of fiddly steps — read on for the details!

Migration steps

  1. Download previous posts from Posterous! Posterous does have an API, and Jekyll includes a posterous importer. The problem with this is I wanted my images as well, and the existing importer didn’t handle that. I hacked it a bit to download the images as well, into a separate directory for each post and as a stop-gap measure just source them in a HTML list. (I submitted a pull request for the importer patch, but haven’t heard back. It’s pretty hackish, but you’re welcome to it.)

  2. This got ugly pretty quickly, so I wrote another hack to upload each image directory to picasa.

  3. Unfortunately, Picasa’s “embedding” functionality seems to be limited to effectively a link to the album on their site, or a shitty flash slideshow. So, I took the smallest lightbox implementation I could find, and wrapped it with this plugin for pulling the image links from picasa’s RSS feed (it saved me writing my own at this point!), and tied them together with a bit of jquery. Instant lightbox, hosted by picasa.

  4. Well, not quite. I wrote a simple little jekyll plugin to wrap some boilerplate HTML around the picasa album-ID, and used an emacs macro to help replace the old image links with that tag. Then I pushed to github, and immediately realised that of course for security reasons they don’t run extra plugins… so I used sed to swap the tags for the boilerplate, and moved on (fortunately it wasn’t a complicated plugin).

  5. Fixing up backlinks. In some posts I have referred to earlier posts, and posterous uses a different link format to jekyll (/title-slug vs /yyyy/mm/dd/often-a-different-slug). I was testing out regular expressions ready to write a script to find all links, trawl the _posts directory looking for which it was likely to refer to and update it… when I realised that there were only 7 such backlinks. So I just fixed them up by hand! (Geek-cred lost, but time gained).

  6. Almost there… I switched to one of the themes provided with jekyll-bootstrap, originally due to Mark Reid. I’d like to do my own at some point, but in the mean time it’s nice and clean. I like it.

And now we’re done! In theory this means I can go back to posting more frequently; in practice it at least means I have less excuses. I’d like to post more technical content as well, but I make no promises. If you’re interested in what I’m reading, I tend to share technical links on Google+ at the moment.

Mark Hepburn 23 June 2012
blog comments powered by Disqus