19 May 2006 » Migrating from Drupal (4.7) to Wordpress
I helped Katie setup her new blog this weekend and decided that WordPress offers much of what I want out of this blog for a lot less effort than drupal1. I decided it might be worth my time to now while this blog is in it's infancy to try converting from drupal to WordPress.
The way I start most of my projects is with a plan:
- Discovery: Find any articles about converting and get a gist of what to do.
- Make the switch when I'm satisfied
I'm really confident that this will be easy. I don't even have to worry about comments or anything, since this blog is pretty new, but I can demonstrate how to take care of the.
I followed most of the instructions, with some alterations from vrypan.net.
I installed WordPress and in
mysql ran the following commands:
use wordpress; delete from wp_categories; delete from wp_posts; delete from wp_post2cat; delete from wp_comments
I run my drupal site in the same database server, so the data copying was a snap. If you aren't so fortunate, just copy the relevant drupal tables temporarily your wordpress database.
USE wordpress; INSERT INTO wp_categories (cat_ID, cat_name, category_nicename, category_description, category_parent) SELECT term_data.tid, name, name, description, parent FROM drupal.term_data, drupal.term_hierarchy WHERE term_data.tid=term_hierarchy.tid;
Again with the posts:
INSERT INTO wp_posts (id, post_date, post_content, post_title, post_excerpt, post_name, post_modified) SELECT DISTINCT n.nid, FROM_UNIXTIME(created), body, n.title, teaser, REPLACE(REPLACE(REPLACE(REPLACE(LOWER(n.title),' ', '_'),'.', '_'),',', '_'),'+', '_'), FROM_UNIXTIME(changed) FROM drupal.node n, drupal.node_revisions r WHERE n.vid = r.vid AND type='story' OR type='page' ;
And the relation between posts and categories:
INSERT INTO wp_post2cat (post_id,category_id) SELECT nid,tid FROM drupal.term_node ;
And finally comments:
INSERT INTO wp_comments (comment_post_ID, comment_date, comment_content, comment_parent) SELECT nid, FROM_UNIXTIME(timestamp), concat('',subject, '<br />', comment), thread FROM drupal.comments ;
I ended up moving the one static page I had into WordPress's "pages" section manually.
Now for the real test. I needed to go through each page on my site and see if I could get to it using the same URLs. Since I had only 14 posts, I did this somewhat manually. I used drupal's built in admin to do this from most popular to least popular. Most URLs worked fine. There were a small number that didn't for various reasons, I used custom
mod_rewrite rules to handle them.
Make the switch
Well, time to make the switch. In the WordPress administration, I just had to tell it that it's now going to be located at
spindrop.us. Then I moved my WordPress installation to the spindrop.us web root. It was a snap. Let me know if you have any troubles.
- Taxonomy, legible URLs and trackback support all seemed quite difficult to master in Drupal. In Wordpress they appeared to be available standard or with a minor change in the administration panels. ↩
- This is a prime reason why URLs should be clean and make sense to the end user, not the programmer of the publishing software. ↩