From MT to WP

Well, I’ve been fiddling with WordPress for a while, and tonight I’ve bit the bullet and made the switch from Movable Type to WordPress. Since I had a heck of a time finding one site that had all the right steps, I’ve decided to document it here for posterity. My biggest challenge was that I had originally started using Brad Choate’s Textile plugin, but had recently switched to Markdown. I decided to go the extra step and convert my MT export entries that were Textile coded into raw HTML. It wasn’t simple. Read on for the detailed instructions.

1. Use Movable Type’s export option to export your data.
2. Use iconv to repair any encoding problems you may run into:

iconv -f ISO-8859-1 -t UTF-8 exported.txt > fixed-export.txt

3. Use `vim` and `perl` (make sure to install `Text::Textile` for `perl`) to convert each Textile entry to raw HTML:

:/^BODY/+,/^EXTENDED BODY/–!perl -e ‘use Text::Textile qw(textile); while (<>) { $html .= $_; }; $foo = textile($html); print $foo;’

4. Do the same thing to your extended entries:

:/^EXTENDED BODY/+,/^EXCERPT/–!perl -e ‘use Text::Textile qw(textile); while (<>) { $html .= $_; }; $foo = textile($html); print $foo;’

5. Install WP, and run through the installation process. Create yourself a user. Install the Markdown plugin if you want.
6. Install the [underscore plugin]( This is because MT uses underscores as it creates the right permalinks, whereas WP uses dashes. Installing this plugin *before* importing your MT data will make them import with underscores. This is a good thing for maintaining your old permalinks.
7. Use WP’s import function to slurp in your exported data.
8. Since MT’s entry permalinks are only 15 characters long, and WP uses the full entry, fire up MySQL and run the following on the WordPress database:

update wp_posts set post_name=SUBSTRING(post_name,1,15);

9. Go to /wp-admin, hit Options, and then Permalinks. Set it to how you preferred your MT permalinks. I used the following format:


10. Edit your .htaccess to redirect key files (such as RSS feeds)

You’re done. This got me 99% of the way there, and the only remaining item I need to trudge through is rebuilding the blogroll, doing a little customizing on the pages, and finally, rebuilding all my tags. Unfortunately, MT’s export format does not export tags. Ugh.