Add new comment

Importing WordPress blogs into Drupal

At Acquia's Migration practice, we import all kinds of content into Drupal. In the course of some recent projects involving imports from WordPress blogs we have put the finishing touches on the WordPress Migrate module, and released it to the community. Built on the framework provided by the Migrate module, it provides a simple way to import WordPress blog posts and pages, as well as associated taxonomy, authors, and files, into a Drupal 7 site. A simple form lets you upload a WordPress export (WXR) file (or even import it directly from the WordPress site), make a few configuration settings, and kick off the import - most modestly-sized blogs will complete in a few minutes. Because it’s built on the Migrate module, you can easily rollback and retry your import with different settings.

Obtaining the WXR export

The input to the WordPress Migrate file is a WordPress WXR file, generated by the Export Tool in the WordPress administrative interface:

You can export this file yourself, then upload it into WordPress Migrate:

Alternatively, you may provide your blog address and credentials, and WordPress Migrate will login to your blog and perform the export itself (the credentials are used immediately on form submission and are not saved anywhere):

Import settings

Once you’ve selected your data source, there are several options you can set to control the import (note that if you have imported before, the form will default to the values from the previous import).

Normally, WordPress blogs contain two types of content - “page” and “post”. The first two selections here, Convert WordPress pages/posts to, allow you to select which Drupal content types you want these items imported as.

Next, if you have any file fields on the Drupal content type you selected for posts, you have the opportunity to populate those fields with attachments from WordPress. This is not required - if you do not select an attachment field, the attached files are still imported, and any images are properly referenced from the post body, but this helps to maintain the relationship between posts and files. If you used the Blubrry PowerPress plugin to manage podcasts in WordPress, you can similarly have them assigned to a file field on your posts.

Following that, you can select what text format will be used for the content bodies in Drupal. If you find after importing that the formatting doesn’t look right, it may mean that the format you chose here does not permit all the HTML tags that were present in the original WordPress post. You can also select a different text format for comment bodies.

WordPress supports two types of taxonomy on posts - tags and categories. You can map those to whatever Drupal vocabularies you like, or ignore them.

You can easily make sure that user bookmarks and search engines don’t lose track of your content when you move it to Drupal. One option is simply to use the same paths in Drupal as you did in WordPress - under Path alias handling, choose Set path aliases to their original WordPress value. On the other hand, if you would like to refactor your paths under Drupal, you can use Pathauto in conjunction with Redirect. Set your alias handling to Have pathauto generate new aliases, and check Generate redirects (important: at this writing migration support has not been committed to Redirect, you need to install a patch for this to work). You will get new Drupal paths according to the patterns you set, and anyone attempting to access your posts through the old paths will get redirected with a 301 (Moved Permanently) HTTP code - i.e., search engines will update their database to reflect the new path.

Running the import

Once you’ve made your choices, simply click Import WordPress blog - the import will run in your browser, bringing you to the Imported blogs tab.

Reviewing and rolling back

Here you will find a list of WordPress blogs you have imported (yes, you can bring in more than one!). Basic stats on how many tags, posts, etc. are provided. You also have the opportunity to back out your import and try it again - just click the Update button with Remove imported content selected. Everything you imported will be deleted - you can then change your import settings and try again.

Once you’re satisfied that your blog is successfully imported, you can remove the tracking overhead from your Drupal database while preserving your imported content by selecting Remove migration bookkeeping and clicking Update.

For more information, please refer to the drupal.org documentation for WordPress Migrate.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Filtered HTML

  • Use [acphone_sales], [acphone_sales_text], [acphone_support], [acphone_international], [acphone_devcloud], [acphone_extra1] and [acphone_extra2] as placeholders for Acquia phone numbers. Add class "acquia-phones-link" to wrapper element to make number a link.
  • To post pieces of code, surround them with <code>...</code> tags. For PHP code, you can use <?php ... ?>, which will also colour it based on syntax.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <h4> <h5> <h2> <img>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.