JustPaste.it

Wordpress to Drupal migration, one way to do it

DrupliconAfter thinking about doing it for many months, I finally converted 2tbsp.com from Wordpress 2 to Drupal 5. I didn't make this move because of anything wrong with Wordpress. Wordpress worked great for the past few years and is an excellent application. The truth is that I am working with Drupal too much now to not use it to power 2tbsp.com.

My goal was to do the migration as quickly as possible with few additions or changes. With the migration now complete, I thought I'd share the basic process I went through.

Wordpress to Drupal Template Conversion

Rather than starting with the Wordpress template source files, I decided to save the old Wordpress home page's HTML source and systematically replace content with Drupal PHPTemplate content variables. This became my new 2tbsp Drupal theme's page.tpl.php.

I copied block, comment, and node template files files from another Drupal theme I recently developed. The theme looked pretty good after transferring CSS to styles.css and after a few find and replaces to update Wordpress class names to common class names in the node template (.submitted, .meta, .node).

Time to Move the Content

The previous version of 2tbsp.com was a hybrid of Wordpress blog posts and a few static web pages. Copy and paste moved the static pages to Drupal page nodes. A Wordpress to Drupal module made light work of migrating the remaining blog posts, comments, users, and categories (see ktiedt's port from 4.7 to 5).

301 Redirects in Apache htaccess

The last major migration step was to redirect the old Wordpress URLs to the new Drupal URLs. Unfortunately, after using the WP migration module, most of the new Drupal node IDs didn't match the original Wordpress post IDs, so writing a single Apache RewriteRule wasn't an option.

I tried using Apache redirect statements in the .htaccess file, but they wouldn't work. After searching drupal.org, I found a post where others shared Apache 301 Rewrite rules. After reviewing the thread, I found a rule to redirect my old Wordpress URLs and query strings (http://2tbsp.com/blog/?p=22) to the migrated Drupal clean URLs (http://2tbsp.com/node/22).

RewriteCond %{QUERY_STRING} p=22
RewriteRule ^blog/? http://2tbsp.com/node/22${pages:%1¦NULL}? [R=301,L]

Finishing Touches

After setting site information (mission, slogan, favicon, etc.) and sidebar blocks, I installed the GeSHi filter to highlight code blocks, like the RewriteRule above. The module did not work after initial the install but after a few path variable updates and a bit of code cleanup, the module started to work in my Drupal multisite environment.

When all was said, done, and tested, the migration had lasted a couple of days and I'm happy with the results. I still would like to display my del.icio.us bookmarks and will need to either upgrade the current del.icio.us module from 4.7 to 5 or see if the aggregator and views modules will do the trick.

Now if I could just find time to design and build a brand new theme...

Related Links

Source: http://2tbsp.com/node/28

 

Author: 2 tablespoons

License: Creative Commons - Share Alike