Imagine you’re working on a local environment, developing a new feature, and you’ve just imported a fresh copy of the project database. Suddenly, all your carefully crafted test content is gone. Nodes, taxonomy terms, and images wiped out.
If you’re a Drupal developer or site builder, you’ve likely experienced this frustration many times. The Default Content module solves this problem by letting you create test content once per project and reliably recreate it in any environment.
Prerequisites:
- A working Drupal site
- The Default Content module installed and enabled
- Drush available on the command line
Here’s How it Works
Default Content transforms your Drupal content into YAML files that live in your codebase. Push those files to git, and every developer on the team gets the same test data automatically. We haven't eliminated the time it takes to create test content, but we make sure it only has to be done once for the whole project.
The workflow is straightforward: build your content in Drupal, then export it with a single drush command. The YAML files must live in a module so Drupal can discover and import them during module installation. In practice, most teams use a small, project-specific “default content” or “demo content” module for this purpose. Default content can also be created in association with Recipes but that is outside the scope of this article.
Let's say you've created a test article with nid 1510:
drush dcer node 1510 my_custom_moduleExport multiple pieces of content by running the command for each node. It takes seconds now but saves hours down the road. To update existing content, simply re-run the export command.
A powerful feature: Default Content automatically exports dependencies. When you export a node that references a taxonomy term, media entity, or other content, those dependencies are exported too. The module handles the import order, so you don't need to manually export taxonomy before nodes. Note that user references are exported by username. If a user doesn't exist in the target environment, you may encounter errors during import. For test content, consider using uid 1 or creating a dedicated test user account across all environments.
Now For The Magic
In any fresh environment, just enable your custom module with drush or the administrative dashboard and watch your test content materialize. Default Content will detect the YAML files in your custom module’s ‘content’ folder and use them to generate content. Database wiped? Fresh install? No problem—your content comes back every time, like it never left.
While nodes are most common, you can also export taxonomy terms, media, menu links, and blocks using the same pattern. Check the module's README for the complete list.
Default Content is purpose-built for test data and starter content, not for syncing editorial changes across environments. Think of it as scaffolding, not a content deployment tool. Master this one module, and you'll never hesitate to wipe your local database. Your test content is always just one command away.
Resources
Default Content module homepage
Need a fresh perspective on a tough project?
Let’s talk about how RDG can help.