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.
Discovery
This post details a migration path from drupal to wordpress. Some considerations had to be made since I’m using drupal 4.7.
Implementation
Copy content
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.
First we get the drupal categories into WordPress:
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.
Since my pages are written in Markdown, I enabled the Markdown for WordPress plugin.
URLs
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.
Adjusting Templates
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.