Submitted by Chris McIntosh on August 14, 2024

Migrating a website from WordPress to Drupal 10 is a common task when seeking more robust and flexible content management features. Drupal provides multiple ways to handle this migration. One of the most user-friendly methods involves using the Feeds module to import a CSV file that contains the exported content from WordPress. In this article, we'll go through a step-by-step process of migrating WordPress content to Drupal 10 using the Feeds module and a CSV file.

Overview of the Process

1. Export WordPress Content: Export WordPress content in a CSV format.
2. Prepare the CSV for Drupal: Structure the CSV file to match the Drupal content types.
3. Install and Configure the Feeds Module: Set up the Feeds module in Drupal 10.
4. Map CSV Fields to Drupal Fields: Map the fields in the CSV to the corresponding fields in Drupal.
5. Run the Import: Use the Feeds module to import the content into Drupal.

Let's dive into each step in detail.

Step 1: Export WordPress Content

WordPress allows you to export your content in XML format via the built-in exporter. However, the Feeds module in Drupal works best with CSV files. You'll need to use a plugin or a conversion tool that can export WordPress content (posts, pages, categories, tags, etc.) directly into a CSV format. Tools like WP All Export are useful for this.

Ensure the CSV contains essential fields like:

  • Title
  • Body content
  • Categories/Tags
  • Author information
  • Published date
  • Featured images (image URLs)

Step 2: Prepare the CSV for Drupal

Before importing the CSV into Drupal, ensure the file is formatted correctly and contains all necessary fields that align with the Drupal content structure. For example, if your Drupal content type has fields like `title`, `body`, `image`, and `category`, ensure the CSV has columns for these fields.

Also, make sure that the data in the CSV file is clean and consistent. Handling edge cases like missing fields, special characters, and date formats can prevent import errors.

Example CSV Structure:

title           body                       category       image               author   published_date      
Welcome to My Blog This is the first post... Blog /path/to/image.jpg admin   2024-08-21 12:00:00
Another Post This is another post... Tutorials /path/to/image2.jpg editor   2024-08-21 13:00:00


Step 3: Install and Configure the Feeds Module

The Feeds module in Drupal allows you to import data from a variety of sources, including CSV files. Here's how you can set it up:

1. Install the Feeds Module: You can install the Feeds module using Composer:

composer require drupal/feeds

    Then, enable the module:

    drush en feeds -y

2. Create a Feed Type: Go to `Admin > Structure > Feed types` and create a new feed type. In this step, you can define the type of content you want to import, such as `Article`, `Blog`, or a custom content type.

3. Configure the Feed Importer:
    - Parser: Select the `CSV` parser.
    - Fetcher: Choose the `File upload` option to upload the CSV file manually.
    - Processor: Set it to `Node`, so the imported data creates content nodes in Drupal.

Step 4: Map CSV Fields to Drupal Fields

After configuring the feed type, you need to map the columns in the CSV to the fields in your Drupal content type.

1. Go to `Admin > Structure > Feed types` and click on the feed type you created.
2. Under Mapping, map the fields from the CSV to the corresponding Drupal fields:
    - Map the `title` column to the `Title` field.
    - Map the `body` column to the `Body` field.
    - If you have an image field, map the image column to the image field in Drupal.

You can also add mappings for other fields like category, tags, and published date.

Handling Taxonomies

If your content involves categories or tags, you'll need to map these to the appropriate taxonomy terms in Drupal. The Feeds module allows you to automatically create taxonomy terms if they don’t already exist.

Step 5: Run the Import

Once the feed type is configured, you can run the import:

1. Go to `Content > Feeds` and select your feed type.
2. Upload the CSV file.
3. Click "Import" to start the process.

The content from the CSV will be imported into your Drupal site, creating nodes with the mapped fields.

Additional Considerations

  • Image Handling: Ensure that image paths are correctly referenced. You may need to adjust image paths if the images need to be downloaded from a remote source.
  •  Content Relationships: If your WordPress content has complex relationships (like related posts or custom metadata), consider using the Migrate module for more control, although it requires more configuration and development.