Content Import
A simple Drupal module to import content from CSV files into any content type with support for various field types and automatic entity creation.
contentimport
Install
composer require 'drupal/contentimport:^10.0'
Overview
Content Import is a straightforward module that enables bulk content creation and updates from CSV files. It provides an easy-to-use administrative interface where users can select a content type, choose whether to create new content or update existing content, and upload a CSV file for import.
The module supports a wide variety of field types including images, entity references (taxonomy terms, users, and nodes), text fields, datetime fields, boolean fields, geolocation fields, geofield, and list fields. One of its key features is the automatic creation of vocabularies, taxonomy terms, and users when they don't exist in the system, making the import process seamless.
The import process runs as a batch operation with progress feedback, and detailed logging is written to a log file for troubleshooting. A sample CSV file generator helps users understand the required format for their content type.
Features
- Import content from CSV files into any Drupal content type
- Create new content or update existing content based on node ID
- Support for image fields with automatic file entity creation from pre-uploaded images
- Entity reference handling for taxonomy terms with automatic vocabulary and term creation
- Entity reference handling for users with automatic user account creation if not exists
- Entity reference handling for content nodes by title
- Support for text fields (text, text_long, text_with_summary) with full HTML format
- Date and timestamp field support with flexible date format parsing
- Boolean field support with multiple true values (On/Yes/on/yes)
- Geolocation field support with single and multiple coordinate values
- Geofield integration for geographic data with WKT point generation
- List (String) field support with comma-separated values
- URL path alias support for SEO-friendly URLs
- Author assignment by username
- Batch processing with progress indicator for large imports
- Import logging to sites/default/files/contentimportlog.txt
- Automatic sample CSV file generation based on selected content type and import mode
- Multi-language support via langcode field
Use Cases
Bulk Content Migration from External System
Export content from an external CMS or database as CSV, map columns to Drupal field machine names, upload images to the designated folder, and import all content in one batch operation. The module automatically creates taxonomy terms and user accounts as needed.
Regular Content Updates from Spreadsheet
Maintain content in a spreadsheet (Excel, Google Sheets), export as CSV, and use the 'Update existing content' mode to bulk update nodes by their node ID. Useful for updating product information, event details, or any regularly changing content.
Initial Site Content Population
When building a new Drupal site, prepare all initial content in CSV format and import it in bulk, rather than creating nodes one by one through the admin interface.
Multi-language Content Import
Import content in different languages by specifying the langcode column in the CSV. Each row can have a different language code, enabling bulk creation of translated content.
Taxonomy-heavy Content Import
Import content with complex taxonomy structures. The module automatically creates vocabularies and terms that don't exist, making it easy to import content with new categorizations without pre-creating the taxonomy structure.
Tips
- Always download the sample CSV after selecting content type to see the exact field machine names required
- Use the log file (sites/default/files/contentimportlog.txt) to debug import issues - it shows detailed status for each field
- For boolean fields, use On/Yes/on/yes for true values, and Off/No for false values
- When importing geolocation or geofield data with multiple points, use semicolon (;) to separate coordinate pairs
- The import runs as a batch process, so large imports won't time out
- To reference existing content nodes, use colon-separated titles: title1:title2:title3
- Author assignment requires the 'author' column with username values - the user must already exist
Technical Details
Admin Pages 1
/admin/config/content/contentimport
Main import form to upload CSV files and import content into Drupal. Users select a content type and import mode, then upload a CSV file. The form dynamically generates a sample CSV file showing required column headers for the selected content type.
Permissions 1
Hooks 1
hook_preprocess_page
Attaches the module's CSS library to the Content Import admin page for custom styling.
Troubleshooting 7
Ensure the sites/default/files/ directory has write permissions for the web server user.
Pre-upload all images to public://<content_type>/images/ folder before importing. Use IMCE module or FTP to upload. The CSV should contain only the filename, not the full path.
Ensure your CSV has 'title' and 'langcode' columns in the first row. These are mandatory for creating new content.
When using 'Update existing content' mode, ensure the nodeid values in CSV correspond to actual existing nodes in Drupal.
For fields with multiple vocabulary targets, use the format 'vocabulary:term1,term2'. For single vocabulary targets, you can omit the vocabulary name.
Use m/d/Y h:m:i format for datetime values or m/d/y for date-only values.
Provide email addresses in the CSV. The module looks up users by email, and creates new user accounts if not found.
Security Notes 3
- The module requires 'administer site configuration' permission, limiting access to trusted administrators
- User accounts created automatically during import are activated immediately - review imported users if importing untrusted data
- CSV file validation only checks file extension - ensure CSV files are from trusted sources before import