Drupal to WordPress Migration Tool

If you’re considering a Drupal to WordPress migration, these resources will help you export your content. Although I feature my own tools here, much of the information presented will be useful regardless of the method you choose.

Many developers and site owners jumped on the Drupal bandwagon in the early 2000s. At that time it was the only real option for a content management system (CMS). While Drupal still has advantages for content rich applications, those with simpler needs are now looking to migrate their sites. WordPress is an ideal alternative because of its smaller footprint, friendly interface, lower maintenance overhead and rich plugin ecosystem.

1. Before you start

Drupal to WordPress migration projects are often complex and need to be handled carefully. Rather than jumping in head-first, take some time to plan your approach. Before continuing, I highly recommend reading my guide, How to prepare for your Drupal to WordPress migration project. Furthermore, you may want to check the resources section for additional worksheets and guides. Also keep in mind that not all aspects of a migration are practical to automate. In many cases, you may need to make manual adjustments post-migration using the WordPress interface.

Incidentally, it’s easy to overlook the fact that you don’t need to make an exact copy of your Drupal site in WordPress. Prioritise the highest value content and functionality if time and budget is tight. To that end, putting together migration requirements will help focus your efforts.

Important reminder

These scripts and tools run MySQL queries to read information from a Drupal database and convert the content to WordPress. They may write temporary tables and make changes to your Drupal content. With this in mind, it’s imporant to avoid working on your live Drupal database. Above all, make backups before using these tools.

2. Migration options

I’ve been migrating sites since around 2011 and conclude that there’s no single method suitable for everyone. Generally speaking, you can:

Migrate manually: If you have a small site and some time on your hands, you can simply copy-and-paste all your content across. It’s an incredibly boring task but sometimes a low-tech solution is what’s needed.

Install a plugin or automated migration software: Several companies offer software that try to migrate content. CMS2CMS and FG Drupal to WordPress appear to be the main choices at the time of writing. CMS2CMS charges a fee calculated from the amount of content you want to migrate. FG Drupal to WordPress, on the other hand, follows a ‘freemium’ model. Since I’ve personally not needed to use this kind of software, I’m unable to comment on how well they perform.

Customise an open-source migration script: The tools I offer fall into this category. Furthermore, there are plenty of scripts and tutorials detailing how you can go about exporting Drupal content into WordPress. Still, you should carefully consider if the time investment and effort needed is worth any monetary savings.

Hire a migration consultant: Since I offer a Drupal to WordPress migration service, it goes without saying that I’d recommend this route as the one giving the best results. Admittedly, budget is an important factor so hiring an expert will consequently be unrealistic for some. Nonetheless, those with heavily customised content types, complex taxonomies or specialised modules may have no other choice.

A quick plug

I give away lots of information for free so here’s a quick plug to keep the lights running. Site migrations are often very time consuming. You can therefore save yourself considerable effort by hiring me to do the job.

3. Web-based Drupal to WordPress export utility

This web-based utility, released in 2013, was my first attempt at building a Drupal to WordPress migration tool. It was based on my in-house scripts to migrate standard content types from Drupal 6 to WordPress 3.5. Although functionality is rudimentary and the tool is no longer being maintained, it might be useful for simple sites if you have a technical disposition. The code uses PHP 4 so you’ll need to make changes to run on modern environments.

Feature list:

Migrates content from Drupal 6 to WordPress 3 and 4 database

Shows number of Drupal terms, node types and entries to be migrated

Select Drupal content types to be converted into WordPress posts

WordPress file directory setting

WordPress permalink structure setting

Select which Drupal terms will be used as WordPress categories

Select the WordPress default category

Web-based content migration: Installation and use

Copy the package folder to a web server.

Edit the MySQL queries. (See below.)

Run the drupaltowordpress.php script on your browser and follow the on-screen instructions to export content.

Both the Drupal and WordPress databases should be on the same server and share the same connection details.

Editing the MySQL queries

While the web front end works with very basic Drupal installations, anything more complicated will need custom SQL queries. These can found in the drupaltowordpress-custom.sql file. The script contains sample values so don’t run it without understanding what will be performed at each step. You’ll need to edit the SQL queries to suit your own Drupal setup. For more information, see the SQL queries section below.

4. Command-line Drupal to WordPress migration tool

I wrote a Python-based command-line tool because the web-based export utility proved too inefficient for complex Drupal configurations. Although it requires more manual editing of MySQL queries, you can more conveniently run heavily customised site migrations.

Command-line content migration: Installation and use

You will need to install the Python modules in the requirements section below.

Rename the settings-template.py to settings.py and edit it to match your migration project settings.

Edit the included SQL sample files in the sql-sample directory to suit your migration requirements. At a minimum, you will need the migration script itself (see the sample migration_standard.sql file).

Run the utility using the help flag to view the available commands:$ python d2w.py -h

Customising the export script for your Drupal setup

The Python script itself won’t perform the migration. To emphasise, you must supply it with an export SQL file containing the migration queries. See the SQL queries section for more information.

Required Python modules

MySQLdb for accessing the backend Drupal and WordPress databases

prettytable for displaying results in a table format

phpserialize for unserializing Drupal fields

Note: all my latest versions of the command-line tool now include a requirements.txt file which you can use with a pip install -r command.

5. Migration SQL queries

Both the web-based and command-line utilities are simply convenient wrappers for SQL queries. While you can run a migration by typing out individual queries in a database client, this will prove to be very tedious for all but the simplest of configurations. In fact, I built these tools precisely because manually entering SQL queries, line-by-line, quickly became unworkable.

It’s important to realize that these queries are the engine of the migration. Consequently, understanding your Drupal database and composing the right SQL queries are key to a successful migration. Because the interface wrappers are useless without the queries, I’ve included a sample set in both packages. For information about customising the export script to suit your Drupal setup, see my step-by-step explanation of the Drupal to WordPress migration SQL queries.

In general, you will need queries to migrate following:

Vocabularies and taxonomies

Drupal nodes to WordPress posts

Users

Comments and comment authors

You may additionally need to include queries to clear out unwanted content, merge terms, or export custom fields.

6. Database tools and migration helper utilities

Content migrations involve spending a great deal of time manipulating the database. It’s therefore useful to have a set of tools to make things easier. Here are some third-party utilities that can help with your migration project:

WP-CLI: A command-line interface for WordPress that I’ve found particularly useful during migration projects. For instance, you can use it for installing a new instance of WordPress, updating user credentials and activating plugins. WP-CLI will save you having to write SQL queries for simple database tasks that go along with a migration project.

Database search and replace script: Sometimes you need a way to search and replace text in the database. This PHP-based tool is useful for environments without command-line access, such as those offered by cloud-based hosting providers.

Drush: A Drupal command-line shell which can be used, for example, in migrating Drupal sites. In particular, you can use it create a development version for analysis prior to exporting to WordPress. As a matter of fact, there’s a drush bam-backup command to backup a site’s database with the Backup and Migrate module.

7. Post-migration troubleshooting

You may encounter problems with your WordPress installation due to the complexity of many migration projects. For example, WordPress might display permissions errors when trying to log in. Furthermore, content that seems to have been migrated may show a ‘Not found’ error. There could be any number of reasons for these problems. Checking my Drupal to WordPress migration notes might point you in the right direction.

8. Other tools, resources and guides

Drupal to WordPress migration worksheet

It’s important to gather as much information possible about your Drupal installation before starting the migration project. You can use my Drupal to WordPress migration worksheet to help structure your investigation process.

How to write a migration mapping document

Preparing a migration mapping document before starting your project will save you time. It simplifies the project by giving everyone a clear idea about the type of content involved. This short overview will get you started with writing a migration mapping.

A Guide for Drupal Developers Migrating to WordPress

This guide from OnTheGoSystems gives Drupal developers an introduction to the WordPress interface. While it doesn’t go through running a content export, it’ll help if you want a quick introduction to using WordPress.

WordPress Codex

Other migration tools

Looking to migrate other types of content? Visit my migration tools page for utilities to migrate content from other platforms.

9. Updates

February 2017: This page has been receiving lots of traffic over the years. I’ve therefore converted it to a general Drupal to WordPress migration resource in the hope that it provides more value to visitors.

August 2015: It’s been some time since I’ve updated the web-based PHP Drupal to WordPress Migration Tool. After a number of Drupal to WordPress migrations, I find the PHP and HTML platform to be inefficient for complex Drupal configurations. pyD2W is my Python-based command line replacement better suited to complex set-ups. View the repository on GitHub.

David Coveney of Interconnect IT Ltd (UK). I used UI elements of Interconnect IT’s WordPress Search and Replace Tool as a starting point to create the in-house scripts on which this tool is based. WordPress (and others) Search and Replace Tool