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:
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.
This post details a migration path from drupal to wordpress. Some considerations had to be made since I’m using drupal 4.7.
I followed most of the instructions, with some alterations from vrypan.net.
I installed WordPress and in
mysql ran the following commands:
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.
First we get the drupal categories into WordPress:
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
Again with the posts:
wp_posts (id, post_date, post_content, post_title,
post_excerpt, post_name, post_modified)
n.nid, FROM_UNIXTIME(created), body, n.title,
REPLACE(REPLACE(REPLACE(REPLACE(LOWER(n.title),' ', '_'),'.', '_'),',', '_'),'+', '_'),
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:
(comment_post_ID, comment_date, comment_content, comment_parent)
concat('',subject, '<br />', comment), thread
FROM drupal.comments ;
I ended up moving the one static page I had into WordPress’s “pages” section manually.
Since my pages are written in Markdown, I enabled the Markdown for WordPress plugin.
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.
My drupal template was fairly clean and simple. So I adjusted the CSS for the default theme in WordPress until I got what I liked. Very minimal changes had to be made to the actual “HTML.”
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.