Migrated from Mephisto to WordPress

I’ve finally migrated this blog from Mephisto to WordPress. I’ve set up redirects, so ideally all the old URLs should still work fine. Apologies for the RSS feed spam, if you got hit with any. Once the dust has settled here, I’ll be migrating the Rubygame blog too.

Why the switch? Simply put, Mephisto wasn’t cutting it anymore. It’s not as usable or polished as WordPress, and it doesn’t feel like it’s going anywhere. Worse, the Rails-based setup was making it difficult to keep up and running, and it was prone to mysterious breakages that would come and go with no apparent cause. In the end, it just wasn’t worth it to me.

For the migration-curious, here’s how I did it.

First I exported the Mephisto database from the web server and imported it to my local MySQL database. Because I was hosting two sites (this blog and the Rubygame blog) using the same Mephisto database (with Mephisto’s multi-site feature), I deleted all the posts and comments associated with the Rubygame site (in other words, all the entries in the “contents” table whose site_id was 1). That way, I was left with just the posts and comments for this blog. (When I migrate the Rubygame blog, I’ll reimport the database dump and do the same, but deleting contents associated with this blog, leaving only the Rubygame contents.)

Then I used m2wp.py with Jason Morrison’s patch and instructions to generate a WXR (WordPress Extended RSS). I imported that to a new local WordPress install (in Tools, Import, WordPress), and cleaned everything up, fixing formatting issues, etc. I used the p2pConverter plugin to convert my two cheatsheets from “Posts” to “Pages”.

Once I was happy with the local setup, I made a new WordPress install on the server hosted in a different directory than my main blog, dumped the database from my local MySQL and uploaded it to the server. Once that was set up, I created some Apache RewriteRules in the .htaccess file to catch URLs from the old scheme and redirect them to the new, correct URLs. Here’s the top part of my Apache config, modified somewhat to fit the format of this blog:

# MEPHISTO -> WORDPRESS REDIRECTS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# Pages
RewriteRule ^articles/2009/8/8/git-submodule-cheat-sheet/?$ \
git-submodule-cheat-sheet [R=301,L]
RewriteRule ^articles/2007/11/17/ruby-c-extension-cheat-sheet/?$ \
ruby-c-extension-cheat-sheet [R=301,L]

# Posts
RewriteRule ^articles/(.+)$ $1 [R=301,L]

# Categories
RewriteRule ^(personal|projects|rubyweekend|ruby|\
rails|snippets|tips|misc)/?$ category/$1/ [R=301,L]

# Archives
RewriteRule ^archives/([0-9]{4})/([1-9])/?$ $1/0$2 [R=301,L]
RewriteRule ^archives/([0-9]{4})/(1[0-2])/?$ $1/$2 [R=301,L]

# RSS
RewriteRule ^feed/atom.xml$ feed/ [R=301,L]
RewriteRule ^feed/comments.xml$ comments/feed/ [R=301,L]
RewriteRule ^feed/([-+_A-Za-z0-9]+)/atom.xml$ category/$1/feed/ [R=301,L]

</IfModule>

I also set up a symlink to the old “assets” folder from Mephisto, where uploaded images and files were stored, since I didn’t think it wasn’t worth the effort to convert them to a new directory structure and set up redirects.

Once that was in place and set up, I changed the server configuration to point this domain to the directory containing the new blog, and voila!

So far, I’ve noticed only a few issues:

  • Drafts were imported as published posts with the current date. I just used WordPress’s Quick Edit feature to change them back to drafts.
  • Comments lost their timestamps, and now just have the same timestamp as the post they’re attached to. Perhaps it could be fixed in the m2wp.py script, but they still keep their relative order, so it’s not a big deal.
  • Comments also lost their formatting. They were imported as Markdown, but probably should have been imported as HTML. There may be a slightly security risk there, though? I’m not sure. Anyway, I fixed the broken comments manually and moved on.
  • The formatting of some posts was/is somewhat broken. Mostly this seems to have to do with how WordPress interprets line breaks and paragraphs within the posts, which conflicts somewhat with the <p> tags and non-meaningful line breaks in the HTML that Mephisto generated from Markdown. I dealt with this by skimming my blog archives and manually fixing any posts that looked wrong, but people who have more posts and are more comfortable with SQL might wish to automate the removal of <p> and line breaks in some way. Alternatively, you could perhaps modify the m2wp.py script to import the original Markdown code instead of the HTML (both are stored in the database, as separate columns), and use a WordPress plugin to interpret the Markdown.

Other than that, everything seems to be working well. It was a fairly smooth transition, thanks to schwuk’s m2wp.py script and Jason Morrison’s patch!

Of course, I still need to find or create a nice blog theme, but no rush there.