Migrating from Movable Type to WordPress

Switching your blog from Moivable Type to WordPress can be a real challenge, especially if your URL structure has changed.

In my case, our blog posts were previously /blog/year/month/post_name_with_underscores.html and under WordPress were going to be simply /post-with-hyphens/

While there are many a fancy regex one can setup in their .htaccess file for 301 redirects, they often involve looping through a recursive regex to replace each individual underscore with a hypen, and then other regexes to do the rest of the work before finally redirecting.

There had to be a better way…

For starters, I downloaded and installed the Redirector WordPress plugin to handle my redirects. This allowed me to a) see what pages were missing via the 404 module and logging and b) import a redirect file to map my old site to my new site.

After moving my posts from Movable Type to WordPress (export your blog posts from MT and then import using the Movable Type and Typepad Importer plugin) I created a custom index template in MT that created the CSV import file of redirects from the old site to the new. Save, Publish, View, Save As, and Import into the redirects in WP and voila! All your old pages go to the new with a 301.

Here are the steps, one by one:

  1. In MT, go to Design | Templates and create a new Index Template
  2. Call it whatever you want and put the following in the actual template
    <mt:Entries limit="150">
    <$mt:EntryPermalink regex_replace="/^.*\.com\//","/"$>, <$mt:EntryPermalink regex_replace="/-/g","_" regex_replace="/^.*[0-9]+\/[0-9]+\/(.+)\.html$/","/$1/"$>, 0</mt:Entries><mt:Pages limit="150">
    <$mt:PagePermalink regex_replace="/^.*\.com\//","/"$>, ___, 0</mt:Pages>
  3. Modify the regex expressions to change to the format that matches your change in scheme. The one above strips off the date, strips off the .html and changes all of the underscores to hyphens. You’ll likely want it do so something else.
  4. If you want to export all your pages, too, you can do so with the last line and a half of code that talks about pages.
  5. Set the output file to oldposts.csv
  6. Save and Publish the template
  7. Go to http://yoursite/blogroot/oldposts.csv
  8. In your browser, File | Save the CSV file to your computer
  9. If you’re on a mac, you’ll need to open this file in Excel and then re-save it in the Windows CSV format. If you’re on Windows, you can skip this step.
  10. Edit the CSV file in your favorite text editor or Excel and if you exported pages, too, enter in the new URL for the pages (replace the ___s).
  11. Log into WordPress and install the Redirects plugin
  12. Go to Tools | Redirects | Options | Import and import your CSV file

C’est fini! Your blog will now redirect requests for your old blog posts to your new format. Enjoy! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *