Software and Other Mysteries

On code and productivity with a dash of unicorn dust.

From Wordpress to Octopress

I thought I would give a quick summary of how I went about migrating from Wordpress to Octopress. It was, in face, a much smoother process than I had expected.

To avoid manually converting all my posts I used exitwp. Okay, admittedly I was actually in the process of doing this manually when I was hit by the realization that there must be a better way, as it turned out there was. I use Mac OS X Lion which comes bundled with Python, which is neat considering exitwp is written in Python. If you don’t use Mac, you’re on your own for this.

Anyway, start off by cloning the exitwp repo. The program has a few dependencies, and if you don’t already have them installed, the best way of grabbing them is probably using Pip. Pip is a package manager of sorts for Python (I’m not a Python guy) and it will make your life much easier (I guess).

Once installed, run you run the pip install command in the exitwp folder, which installs the dependencies. You are now set for the actual conversion. Below you will see the commands that you either already typed, or will copy-paste in about two seconds.

1
2
3
4
$ git clone https://github.com/thomasf/exitwp
$ curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python
$ cd exitwp
$ sudo pip install --upgrade  -r pip_requirements.txt

Next step is getting your data from Wordpress. Thankfully the folks at WP has made this easy. Simply log in to your admin area, go to Tools -> Export and grab all your posts as XML. Save the XML file in your exitwp/wordpress-xml directory.

Now all that remains is running python exitwp.py and your posts will be converted to Octopress-compatible markdown files in the exitwp/build directory. Move the newly generated files to your Octopress source/_posts folder and you will soon be able to relax.

By now your blog should be working, and if it doesn’t I’m afraid you will actually have to read the text on all those other sites. A few tweaks remain if you wish to remain somewhat backward compatible when replacing the Wordpress site with your fancy new Octopress ditto.

If you used tags in WP for your posts, the converter will unfortunately still lists them in the post header as tags. You will have to change all tags: to categories:. A quick search-and-replace should do the trick. Secondly, since categories were called tags, and were thus located at /tag/ in the URL hierarchy, you might want to set category_dir: tag in _config.py to remain backward compatible.

Speaking of backward compatability. If you also want to make sure that old permalinks will still work, you might have to change the permalink setting as well. I set mine to /:year/:month/:title/, which was the same as I had in WP.

That was it for me at least. I hope your ride will be just as smooth if you decide to make the switch.

Comments