{"id":13760,"date":"2009-02-17T09:22:26","date_gmt":"2009-02-17T16:22:26","guid":{"rendered":"http:\/\/hill-kleerup.org\/blog\/?p=13760"},"modified":"2009-02-17T10:51:55","modified_gmt":"2009-02-17T17:51:55","slug":"converting-from-movable-type-to-wordpress","status":"publish","type":"post","link":"https:\/\/hill-kleerup.org\/blog\/2009\/02\/17\/converting-from-movable-type-to-wordpress.html","title":{"rendered":"Converting from Movable Type to WordPress"},"content":{"rendered":"<p>Okay, here&#8217;s my stab at what I did and why. This is a conversion from a Movable Type 4.01 blog (set up with dynamic publishing for everything except the <em>index.html<\/em>) to WordPress 2.7.<\/p>\n<p>Of course, you should check out the documentation on installation, starting <a href=\"http:\/\/codex.wordpress.org\/Getting_Started_with_WordPress\" target=\"_blank\">here<\/a>, most specifically <a href=\"http:\/\/codex.wordpress.org\/Installing_WordPress\" target=\"_blank\">the standard installation doc<\/a>&nbsp;(and for the most part here I won&#8217;t repeat its info, just point out areas where I varied from it or where there was specific application of some points to my work). Print it out, scribble notes. etc. There&#8217;s also a specific and very useful WP codex document on <a href=\"http:\/\/codex.wordpress.org\/Importing_from_Movable_Type_to_WordPress\" target=\"_blank\">importing from MT<\/a> (there&#8217;s also an interesting, if bigger-scale project described <a href=\"http:\/\/birdhouse.org\/blog\/2008\/02\/07\/notes-on-a-massive-wordpress-migration\/\" target=\"_blank\">here<\/a>, and you can find a lot of info on the subject via Google, though of varying value, currency, or technical expertise).<\/p>\n<p>I have multiple MT blogs. WordPress seems to offer three choices to handle that:<\/p>\n<ol>\n<li> Use a multi-blog setup like <a href=\"http:\/\/codex.wordpress.org\/WordPressMU\" target=\"_blank\">WordPressMU<\/a>.&nbsp;<\/li>\n<li> Create multiple blogs within the same WP database in MySQL (with each blog&#8217;s tables having their own prefix).<\/li>\n<li> Create multiple WP databases in MySQL (with the tables inside all being standard).<\/li>\n<\/ol>\n<p>For mostly aesthetic reasons, I decided on #2. This document just addresses the movement of my main blog from MT to WP.<\/p>\n<p><!--more--><\/p>\n<p>As prep work, I saved copies (printouts and source files) of my front page, my CSS flie, etc., for future easy reference. I&#8217;m not actually deleting the blog out of MT (yet), but they&#8217;ll be convenient.<\/p>\n<p>1. I did a test conversion on a little blog I had that made no difference. That informed some of the below choices, and gave me the confidence that I wasn&#8217;t going to royally mess things up.<\/p>\n<p>2. I had over 13,500 entries in my MT blog, so I knew that the WP import routine (limited to 2Mb files) would choke. I created an MT index template that emulated the Export output, but let me choose a subset of the files at the time. You can find examples of this around on the Net. I essentially had an <em>&lt;MTEntries lastn=&#8221;500&#8243; offset=&#8221;0&#8243;&gt; <\/em>container for the template, and had it associated with an export file <em>export1.txt<\/em>. I&#8217;d run it, and when it finished, I&#8217;d go in, increase the offset by 500 (offset = &#8220;500&#8221;, etc.) change the file to <em>export2.txt<\/em>, and repeated.&nbsp;<\/p>\n<p>This took 28 iterations (i.e., up to <em>export28.txt<\/em>), and then I went through and validated the start\/end dates of the posts in each one to make sure I hadn&#8217;t goofed up and missed anything. And, in fact, I had, so that double-check kept me from losing 500 entries.<\/p>\n<p>An alternative to this would have been to tried to run the full export out of MT as normal, then manually break up the file through a text editor. There was an original reason I didn&#8217;t do this (I wanted to save the post ID in the export file), but it didn&#8217;t matter in the end, so that&#8217;s a fully workable alternative.<\/p>\n<p>3. One of the biggest challenges I faced was in not wanting to lose my copious internal links within my blog, both trackbacks and simple links. The complications are that there were three different types of permalinks to the files. From 8\/01 to 12\/05, archives used the post number for the file name, e.g., <em>\/blog\/mtarchive\/0045678.html<\/em>. After that, I started using a 15-byte dirified title, e.g., <em>\/blog\/2007\/04\/18\/happy_anniversa.html<\/em>. In 9\/06, I changed that to a dirified title of up to 25 bytes, e.g., <em>\/blog\/2009\/01\/05\/happy_birthday_to_me_tod.html<\/em>&nbsp;<\/p>\n<p>The codex document &#8220;<a href=\"http:\/\/codex.wordpress.org\/Importing_from_Movable_Type_to_WordPress\" target=\"_blank\">Importing from Movable Type to WordPress<\/a>,&#8221; though obsolete in some generalities, summarizes well how to do this conversion, and offers a variety of strategies. I early on decided I didn&#8217;t want to do a massive mod_rewrite section in my .htaccess file, nor did I want to generate 14K post files that did redirections. I decided (and determined through experimentation with that same test blog) that I could get by on the dirified titles, though there were a couple of complications:<\/p>\n<ul>\n<li> WP could create dirified titles for the posts, but at its own length and using hyphens, not underscores, for blanks. This could be mostly&nbsp;solved through manipulation of the filenames in the database (insert ominous chord here).<\/li>\n<li> I tend to reuse post titles frequently. That means I might have multiple dirified titles with a sequence appended by MT (<em>get_lost1, get_lost2, get_lost3<\/em>), which keeps them from being duplicated within the system. It wasn&#8217;t clear to me that WP would add sequences that way, but if it did, it would do in the sequence the files were loaded, which might not match.<\/li>\n<li> MT generates the basename of the file (when using directories) at the time the title is first saved. If I renamed a post, or spotted a typo and corrected it, the basename and the title would be out of sync. WP would generate the postname for the file based on the current title, not on what was in there as the basename.<\/li>\n<\/ul>\n<p>I figured I could work around, deal with, or simply shrug off the items in those bullets. The numeric posts, though, were a major problem, since while MT still operated it would route any requests (through mtview.cgi) to the proper MT post, but once MT was turned off for that blog, WP would have no clue as to what post was being referenced.<\/p>\n<p>So I spent the better part of a couple of days going through each of the export files, double-clicking on any numeric post titles I found in it. which pulled up the MT post. There I&#8217;d go to the permalink at the bottom of the post, which was the currently generated baseline dirified name. I&#8217;d copy that over into the export file to replace the numeric filename, then go on to the next.<\/p>\n<p>Yes, that did take a lot of time. There were probably 400-500 of them I needed to do.<\/p>\n<p>But when I was done, all of the internal links within the blog were with the dirified name styles that I could make use of in WordPress.<\/p>\n<p>3.5 I also, while I was at it, converted each file to UTF-8 in my text editor.<\/p>\n<p>4. I went through the next couple of standard steps in the install: upload the files set the <em>wp-content <\/em>folder to 777; updated the <em>admin.php <\/em>file to reflect the userid, password, and database table prefix; etc. I installed WP into a subdirectory under the blog, i.e., <em>\/blog\/wp<\/em>, and&nbsp;I had the blog running from within that WP directory (for the moment; that meant that both blogs would be operating at the same point).<\/p>\n<p>5. I imported the 14 files up into WP, roughly oldest to newest (though, of course, the first posts within each file was the newest, so the sequence was all messed up anyway).<\/p>\n<p>While this was going on, I did some messing around with the general settings in WP, turned on Akismet, played with the Theme, etc. I also added in the CSS bits from the old blog that I was going to need in the new one (including my drop shadow image codes).<\/p>\n<p>6. I set the default filename format for files to <em>\/%year%\/%monthnum%\/%day%\/%postname%.html<\/em>; that created file formats that were very close to the legacy filenames from MT.<\/p>\n<p>7. Now came the (ominous chord) manipulation of the database to hammer the WP-assigned&nbsp;filenames to match the old MT dirified format. I basically used the update queries from the <a href=\"http:\/\/codex.wordpress.org\/Importing_from_Movable_Type_to_WordPress\" target=\"_blank\">MT conversion doc<\/a>, in phpAdmin:<\/p>\n<ul>\n<li> <strong>UPDATE wp_posts SET post_name=SUBSTRING(post_name,1,15) WHERE post_date &lt; &#8216;2006-09-08&#8217;<\/strong>: For posts older than 8 Sept 2006, truncate the filename down to 15 bytes. (Note that the total of the records affected will not equal the number of posts in that time frame, because some are already shorter than 15 bytes.)<\/li>\n<li> <strong>UPDATE wp_posts SET post_name=SUBSTRING(post_name,1,25) WHERE post_date&nbsp;&gt;= &#8216;2006-09-08&#8217;<\/strong>: For posts newer than that, truncate the filename down to 25 bytes. (Ditto on query hits.)<\/li>\n<li> <strong>UPDATE wp_posts SET post_name=REPLACE(post_name, &#8216;-&#8216;, &#8216;_&#8217;)<\/strong>: Change the use of hyphens (WP style) to underscores.<\/li>\n<li> <strong>UPDATE wp_posts SET post_name = SUBSTRING(post_name,1,(length(post_name) -1)) WHERE RIGHT(post_name,1) = &#8216;_&#8217;<\/strong>: MT drops a trailing underscore (blank), so that <em>happy_birthday_ <\/em>is actually turned into <em>happy_birthday<\/em>. Do that same thing.<\/li>\n<\/ul>\n<p>Note that these changes are such that they only affect those legacy posts; new posts going forward will still use the newer (hyphenated) WP format, and that&#8217;s okay.<\/p>\n<p>Once this was done, I figured a good 90% of the internal links were correct. The exceptions would be ones with numeric suffixes and cases where titles were changed. That wasn&#8217;t as high as would be ideal, but it will hopefully do. Where gaps are uncovered, I can update the manually in the future (esp. since I&#8217;ll have the post title in the filename).<\/p>\n<p>8. At this point, I was ready to make the WP version&nbsp;The Blog. I couldn&#8217;t run the old one at the same time, due to all of the dymamic bits and how the two were going to bump heads in<em> .htaccess<\/em> if they were both running in <em>\/blog\/<\/em>. So I &#8230;<\/p>\n<ul>\n<li> In the WP admin screen, I changed the blog publishing point to be \/blog\/, rather than \/blog\/wp.<\/li>\n<li> I copied the .htaccess suggestions into the .<em>htaccess <\/em>file in <em>\/blog\/<\/em>. I also copied the <em>index.php <\/em>from <em>\/blog\/wp <\/em>to <em>\/blog\/<\/em> (these items per the admin screen). I took out the MT-generated <em>mtview.php <\/em>mod_rewrites (copying it into a text file for safekeeping) from <em>.htaccess<\/em> as well.&nbsp;<\/li>\n<li>\n<p>I changed the .htaccess file in the <em>\/blog\/mtarchive<\/em> directory to reroute requests, instead of to <em>\/blog\/mtview.php<\/em> to <em>\/blog\/index.php<\/em>, i.e., into WP. This came into play in the next step.<\/p>\n<\/li>\n<\/ul>\n<p>9. I&#8217;d found, in my poking around, a nifty plug-in called <a href=\"http:\/\/wordpress.org\/extend\/plugins\/redirection\/\" target=\"_blank\">Redirection<\/a>. This does a spiffy job of recording 404 (file not found) errors within WP, as well as letting you set up redirections, e.g., &#8220;if you get a request for X, redirect it to Y, and send back an error code 301 so search engines know about the change.&#8221; It will even notice when you change a title (thus changing the filename) and creates a redirection based on that.<\/p>\n<p>So I installed that plug-in, then I went to Google Analytics to get a list of the top 100 URLs gone after on my blog. For the ones that were numerics <em>(\/blog\/mtarchive\/00123456.html)<\/em>, I clicked on them to get routed to the correct WP page (the mtview.php redirections in the mtarchive folder were routing through at this point to WP, which knew about them because I&#8217;d changed the filenames). Then I put the old mtarchive file name and the correct WP filename into a redirection record in Redirection. I did that with about 20 of the most popular old posts, figuring that would handle the majority of the traffic.<\/p>\n<p>10. And that just left some housecleaning. My own checklist (some of which I&#8217;ve&nbsp;already done as of this writing)&nbsp;includes:<\/p>\n<ul>\n<li> Turn off the old MT cron jobs (for delayed posting &#8212; though it occurs to me I&#8217;ve used those for my remaining MT blogs, so they may get turned back on).<\/li>\n<li> Share something with a note up in Google Reader to let folks know that my feeds have likely changed (I sent out a &#8220;last call&#8221; post before the conversion). Remember that a lot of blog audience members read via RSS &#8212; and if your feed addies have changed, they may not recognize the change for days or weeks.<\/li>\n<li> Update Feedburner with the current feed.<\/li>\n<li> Review categories. Re-hierarchialize the cats and sub-cats.<\/li>\n<li> Add in Google Analytics info (use <a href=\"http:\/\/cavemonkey50.com\/code\/google-analyticator\/\" target=\"_blank\">Analyticator<\/a>?)<\/li>\n<li> Update my ecto\/Linear configuration to point to the new WP blog. (Works like a champ.)<\/li>\n<li> Configure &#8212; both in Linear and in WordPress &#8212; what sites get pinged when I post something.<\/li>\n<li> Get posting-by-email working (it supposedly works out of the box with WP, with some configuration).<\/li>\n<li> Configure Flickr to be able to blog to the new site (as it was able to the old site). Again, this worked pretty easily.<\/li>\n<li> Update the About page, and create a Contact page.<\/li>\n<li> Figure out about using Twitter (blogging tweets, turn blog posts into tweets, etc.). Ponder about this &#8212; meantime, <a href=\"http:\/\/alexking.org\/projects\/wordpress\/readme?project=twitter-tools\" target=\"_blank\">Twitter Tools<\/a> looks good.<\/li>\n<li> Review the anti-spam (and CAPTCHA?) capabilities of WP and the blog as configured. WP comes out of the box with Akismet, which in a few days has performed pretty well. I&#8217;m going to hold off a bit with any other protections until it seems necessary.<\/li>\n<li> Review what I had on my old front page (from the printouts) and consider what (and how) to implement it.<\/li>\n<li> Plug-ins! Plug-ins! Plug-ins!<\/li>\n<\/ul>\n<p>Eventually I&#8217;ll&nbsp;delete the blog from my MT database, and clean off or archive the old static files. And, of course, as I have multiple&nbsp;blogs, I&#8217;ll eventually be converting them over as later projects, after which I can, in theory, delete the MT installation altogether.<\/p>\n<p>And that&#8217;s the story thus far. Any questions?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Okay, here&#8217;s my stab at what I did and why. This is a conversion from a Movable Type 4.01 blog (set up with dynamic publishing for everything except the index.html) to WordPress 2.7. Of course, you should check out the documentation on installation, starting here, most specifically the standard installation doc&nbsp;(and for the most part &hellip; <a href=\"https:\/\/hill-kleerup.org\/blog\/2009\/02\/17\/converting-from-movable-type-to-wordpress.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Converting from Movable Type to WordPress&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[55],"tags":[],"class_list":["post-13760","post","type-post","status-publish","format-standard","hentry","category-blogging-technical"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":11241,"url":"https:\/\/hill-kleerup.org\/blog\/2007\/10\/14\/movable_type_and_flickr.html","url_meta":{"origin":13760,"position":0},"title":"Movable Type and Flickr","author":"***Dave","date":"Sun 14-Oct-07 7:46pm","format":false,"excerpt":"So a couple of months ago, I was having problems with Flickr,and it's \"e-mail-to-blog\" functionality.\u00a0 No matter what I tried, it threw back and error when I tried to post...","rel":"","context":"In &quot;Blogging &amp; Internet&quot;","block_context":{"text":"Blogging &amp; Internet","link":"https:\/\/hill-kleerup.org\/blog\/category\/blogging"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10398,"url":"https:\/\/hill-kleerup.org\/blog\/2007\/01\/29\/the_future_is_murky.html","url_meta":{"origin":13760,"position":1},"title":"The Future is &#8230; Murky!","author":"***Dave","date":"Mon 29-Jan-07 7:13am","format":false,"excerpt":"One of the biggies about the Movable Type 3.34 upgrade was its built-in, out-of-the-box support for FastCGI, a remain-memory-resident implementation of the CGI used to run the MT scripts. Since...","rel":"","context":"In &quot;Blogging &amp; Internet&quot;","block_context":{"text":"Blogging &amp; Internet","link":"https:\/\/hill-kleerup.org\/blog\/category\/blogging"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10469,"url":"https:\/\/hill-kleerup.org\/blog\/2007\/01\/08\/mt_plug_ins_on_parade.html","url_meta":{"origin":13760,"position":2},"title":"MT Plug-ins on Parade!","author":"***Dave","date":"Mon 8-Jan-07 11:16am","format":false,"excerpt":"For you Movable Type users out there, 6A is having a survey of \"official\" plug-ins -- which ones are used, which ones should be bundled with the installation, which one...","rel":"","context":"In &quot;Blogging &amp; Internet&quot;","block_context":{"text":"Blogging &amp; Internet","link":"https:\/\/hill-kleerup.org\/blog\/category\/blogging"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10001,"url":"https:\/\/hill-kleerup.org\/blog\/2006\/09\/27\/movable_type_security_ale.html","url_meta":{"origin":13760,"position":3},"title":"Movable Type security alert","author":"***Dave","date":"Wed 27-Sep-06 10:47pm","format":false,"excerpt":"SixApart is releasing what it's calling \"required updates for both Movable Type and Movable Type Enterprise to fix a number of vulnerabilities affecting all previous versions of the platform,\" bringing...","rel":"","context":"In &quot;Blogging &amp; Internet&quot;","block_context":{"text":"Blogging &amp; Internet","link":"https:\/\/hill-kleerup.org\/blog\/category\/blogging"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8996,"url":"https:\/\/hill-kleerup.org\/blog\/2006\/03\/08\/shifting_a_blog.html","url_meta":{"origin":13760,"position":4},"title":"Shifting a blog category to another blog in Movable Type","author":"***Dave","date":"Wed 8-Mar-06 1:32pm","format":false,"excerpt":"Notes to self, after checking out the MT import\/export support forum: Learning Movable Type: Moving an Entry from One Blog to Another WizbangTech: Cloning Movable Type Categories (someone else's take...","rel":"","context":"In &quot;Blogging &amp; Internet&quot;","block_context":{"text":"Blogging &amp; Internet","link":"https:\/\/hill-kleerup.org\/blog\/category\/blogging"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":12011,"url":"https:\/\/hill-kleerup.org\/blog\/2007\/12\/13\/open_source_movable_type.html","url_meta":{"origin":13760,"position":5},"title":"Open Source Movable Type","author":"***Dave","date":"Thu 13-Dec-07 1:44pm","format":false,"excerpt":"Quoth Anil Dash: As of today, and forever forward, Movable Type is open source. This means you can freely modify, redistribute, and use Movable Type for any purpose you choose....","rel":"","context":"In &quot;Blogging &amp; Internet&quot;","block_context":{"text":"Blogging &amp; Internet","link":"https:\/\/hill-kleerup.org\/blog\/category\/blogging"},"img":{"alt_text":"mt4-bug-mt-white.png","src":"https:\/\/i0.wp.com\/www.movabletype.org\/mt4-bug-mt-white.png?resize=350%2C200","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/hill-kleerup.org\/blog\/wp-json\/wp\/v2\/posts\/13760","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hill-kleerup.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hill-kleerup.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hill-kleerup.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hill-kleerup.org\/blog\/wp-json\/wp\/v2\/comments?post=13760"}],"version-history":[{"count":0,"href":"https:\/\/hill-kleerup.org\/blog\/wp-json\/wp\/v2\/posts\/13760\/revisions"}],"wp:attachment":[{"href":"https:\/\/hill-kleerup.org\/blog\/wp-json\/wp\/v2\/media?parent=13760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hill-kleerup.org\/blog\/wp-json\/wp\/v2\/categories?post=13760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hill-kleerup.org\/blog\/wp-json\/wp\/v2\/tags?post=13760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}