content_migration_porter
Content Porter is a Drupal module used to migrate content from one Drupal project to another Drupal project using a JSON export and import process.
The module is intended for cases where content needs to be moved between Drupal sites, such as from a development site to a staging site, from staging to production, or from one project instance to another.
The Drupal.org project is named Content Migration Porter. The module provided by this project is Content Porter.
Content Porter focuses on moving the actual content data. It does not automatically create the site structure, such as content types, fields, media types, paragraph types, taxonomy vocabularies, or custom block types. The destination site should already have the required structure before importing content.
How Content Porter works
Content Porter must be installed on both the source Drupal site and the destination Drupal site.
On the source site, administrators use the export page to select the type of content they want to export. The export form provides options for supported entity types such as content, custom blocks, and media. After selecting the required type, the administrator can choose the specific items that need to be exported.
When the export is submitted, Content Porter collects the selected content and its supported related entities, then generates a JSON export file. This JSON file can then be downloaded and used on another Drupal site.
On the destination site, administrators use the import page to upload the JSON file generated by Content Porter. The module reads the JSON data and creates the content on the destination site.
Recommended migration flow
For a successful migration, the destination site should have the same structure as the source site before importing content.
If the destination site does not already have the required content types, fields, paragraph types, media types, taxonomy vocabularies, or custom block types, use the Config Entity Exporter module first to migrate the required configuration.
Recommended flow:
- Install Config Entity Exporter on the source and destination sites.
- Use Config Entity Exporter to export the required configuration from the source site.
- Import the configuration on the destination site.
- Confirm that the destination site has the same content types, fields, paragraph types, media types, taxonomy vocabularies, and custom block types.
- Install Content Porter on both the source and destination sites.
- Use Content Porter on the source site to export the selected content as JSON.
- Use Content Porter on the destination site to import the JSON file.
This allows configuration to be migrated first, followed by content migration.
Important requirement
The destination Drupal site should already have the same structure as the source site before importing content.
This means the following should already exist on the destination site:
- Same content types
- Same field machine names
- Same field types
- Same paragraph types, if paragraph fields are used
- Same media types, if media fields are used
- Same taxonomy vocabularies, if taxonomy terms are used
- Same custom block types, if custom blocks are used
Content Porter imports the content data into the existing structure. It does not replace Drupal configuration management and it does not automatically create missing content types, fields, or other configuration on the destination site.
Export process
To export content, go to:
Administration -> Content -> Content Porter -> Export content
The export process works as follows:
- Select the entity type to export, such as content, custom block, or media.
- Select the bundle or type, such as a content type, custom block type, or media type.
- Select the individual items that should be exported.
- Submit the export form.
- The module generates a JSON file containing the selected content data and supported related entity data.
- Download the JSON file.
The exported JSON file can then be used on another Drupal site where Content Porter is installed.
Import process
To import content, go to:
Administration -> Content -> Content Porter -> Import content
The import process works as follows:
- Install and enable Content Porter on the destination Drupal site.
- Make sure the destination site has the same content types, fields, media types, paragraph types, taxonomy vocabularies, and custom block types as the source site.
- Upload the JSON file exported from the source site.
- Submit the import form.
- The module reads the JSON file and creates the content on the destination site.
Supported content
Content Porter is designed to support exporting and importing content and related entities such as:
- Nodes/content
- Custom blocks
- Media
Support depends on the field structure available on both the source and destination sites.
Additional Requirements
This module requires Drupal 10 or Drupal 11.
Required Drupal core modules:
- Node
- Taxonomy
- Media
- File
- Block Content
Required contributed modules:
- Paragraphs
Recommended companion module
Config Entity Exporter is recommended when the destination site does not already have the required structure.
Use Config Entity Exporter before Content Porter if you need to move configuration such as:
- Content types
- Fields
- Paragraph types
- Media types
- Taxonomy vocabularies
- Custom block types
- View modes
- Form displays
After the required configuration is available on the destination site, use Content Porter to move the actual content.
Similar projects
Drupal core provides configuration management for exporting and importing site configuration. Content Porter is different because it focuses on selected content export and import through an administrator interface.
Migration-focused modules can be used for larger migration workflows. Content Porter is intended for simpler selected-content movement between Drupal sites that already share the same structure.
Security note
Only trusted administrators should be allowed to use Content Porter.
The import feature creates content from an uploaded JSON file. Because of this, JSON files should only be imported from trusted sources. Do not allow untrusted users to upload or import Content Porter JSON files.