It is no surprise that you now get a blog post about how we quickly migrated our previous blog posts from Drupal 6.9 to WordPress 2.7. While our method was quick and dirty, someone could create a good set of scripts by following this through.
As most of us are prone to do, we spent about 45 minutes searching through Google for options to perform the upgrade. The most relevant find was this post from darcynorman.com in which a script was available for bringing Drupal blog posts into WordPress post. Not only did the script look like it brought over the posts, but also comments and categories.
While the script was created for Drupal 5, not too much has changed in the standard structure of Drupal nodes for use by this script. Unfortunately the structure of WordPress has in fact changed since the script was written for version 2.1 and we were migrating to 2.7.
All in all, this was not too much of a problem since the WordPress site was brand new with no existing content. We simply recreated the site using WordPress 2.1, ran our Drupal to WordPress sql script and then upgraded WordPress to 2.7. Voila! Not bad.
Here are a few caveats.
- Categories – The script takes your Drupal Taxonomy and makes the entries Categories in WordPress. In our case, we really needed those as tags rather than categories. A quick update statement “UPDATE wp_term_taxonomy SET taxonomy=’post_tag’;” (Be sure to do this BEFORE you do anything else with your categories or tags on WordPress)
- Comments – You might want to order the comments selected from Drupal so that the most recent comments are last. Otherwise the WordPress dashboard will show the oldest comments as the most recent.
- Author – You will need to update the post_author column of the wp_posts table to get a proper mapping to WordPress user. You will want to create the necessary users first before updating the post_author field.
- URL’s – In WordPress the “slug” is the url alias for the post. Watch out for puntuation in the titles, they won’t work well for you if you are using more SEO friendly formats. In particular we had issues with (-) hyphens, (/) slashes and ({}) curly braces. Where these existed, we needed to remove them from the “slug” for the post.
Now, in order to get the old url’s to redirect from the previous Drupal site to the new WordPress site. Seems to me that a 301 permanent redirect is the proper way to handle this. On our servers we can do that easily in the .htaccess file.
There are two approaches here. (1) Redirect all content in the blog directory or (2) write a query to create individual 301 redirect statements for each blog url and place them in the .htaccess file.
Since our blog has less than 100 entries and the URL’s are similar between the Drupal and WordPress sites, we chose option 1. The reason we chose this was the minimal effort when used in combination with the Smart 404 plugin for WordPress. This plugin works similarly to the Drupal Search 404 module. This worked beautifully for redirecting to the correct blog post from the old URL’s.
So, in our Drupal instance we are also using the pathauto module and had all the blog posts under a /content/[title-raw] alias structure. This made it easy to redirect all content with /content/ in the url to the new blog. We added the following to our .htaccess file on the Drupal site:
# Redirect blog posts to new blog site
Redirect 301 /content/* http://blog.tech4him.com/*
And with that, we were done with a quick and dirty move from Drupal to WordPress.
Now again,
Popularity: 3% [?]