Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

Generated Content

77 sites No security coverage
View on drupal.org

This module allows you to programmatically generate content in Drupal. You can create your own content generators or use predefined ones to populate your site with consistent or random content for testing and development.

Drupal module to programmatically generate content.

Development takes place in GitHub repository https://github.com/AlexSkrypnyk/generated_contentt

User stories

As a site owner
I want to see generated content before I have content
So that I can see how my site looks

As a Drupal developer
I want to control what is put into generated content
So that I have control over what is being generated

As a Drupal developer
I want to have a list of pre-generated pages with URLs
So that I can use them for Visual Regression testing during site releases

Installation

composer require drupal/generated_content

How it works

  1. The module uses Drupal's plugin system to discover content
    generators. Each generator is a PHP class with a
    #[GeneratedContent] attribute in your module's
    src/Plugin/GeneratedContent/ directory.

  2. The module provides a helper (singleton) class to generate random
    and static content. It also supports extending this class in your custom
    module to enhance with your site-specific generation helpers.

  3. Generated content entities are tracked in the Repository so that
    they could be referenced from other generated entities (e.g., generated
    Articles using generated Tags).

  4. Content can be generated from UI
    /admin/config/development/generated-content or through a
    Drush command
    drush generated-content:create-content {entity_type} {bundle}.

  5. Content can also be generated on module install if
    GENERATED_CONTENT_CREATE environment variable is set to
    1. Generation can be further filtered by specified types in
    GENERATED_CONTENT_ITEMS environment variable as a
    comma-separated list of {entity_type}-{bundle} values:

    # Generate all items in my_module module when it is enabled.
    GENERATED_CONTENT_CREATE=1 drush pm-enable my_module
    
    # Generate only selected items in my_module module when it is enabled.
    GENERATED_CONTENT_CREATE=1 GENERATED_CONTENT_ITEMS=media-image,taxonomy_term-tags,node-page drush pm-enable my_module

See test example module
1
and test example
module 2
for extensive examples.

The module supports
hook_generated_content_plugin_alter() to alter plugin
definitions at runtime.

Difference with Devel
Generate

Devel Generate and Generated Content are two different tools for
creating content in Drupal. Devel Generate is mainly used for generating
random dummy content, users, and taxonomy terms for testing and
development. It allows you to specify how many and what types of
entities to create, but the content is random.

On the other hand, Generated Content is for creating specific sets of
content based on predefined settings. It is useful for ensuring the same
content is produced each time, which is helpful for tasks like Visual
Regression testing where consistency is key. Unlike Devel Generate,
which is more about quick, random content, Generated Content is about
having control and reproducibility for structured content setups.

Generated Content does not provide any generators itself, but it
allows you to create your own generators and provides a harness to run
them.

Example to generate Tags

<?php

declare(strict_types=1);

namespace Drupal\my_module\Plugin\GeneratedContent;

use Drupal\Core\Link;
use Drupal\generated_content\Attribute\GeneratedContent;
use Drupal\generated_content\Plugin\GeneratedContent\GeneratedContentPluginBase;
use Drupal\taxonomy\Entity\Term;

#[GeneratedContent(id: 'my_module_taxonomy_term_tags', entity_type: 'taxonomy_term', bundle: 'tags', weight: 12)]
class TaxonomyTermTags extends GeneratedContentPluginBase {

  public function generate(): array {
    $total_terms_count = 10;

    $terms = [];

    for ($i = 0; $i < $total_terms_count; $i++) {
      $term = Term::create([
        'vid' => 'tags',
        'name' => 'Generated term ' . ($i + 1),
      ]);

      $term->save();

      $terms[] = $term;

      $this->helper::log(
        'Created "%s" term "%s" [ID: %s] %s',
        $term->bundle(),
        $term->toLink()->toString(),
        $term->id(),
        Link::createFromRoute('Edit', 'entity.taxonomy_term.edit_form', ['taxonomy_term' => $term->id()])->toString()
      );
    }

    return $terms;
  }

}

Generation helper

Generation helper class GeneratedContentHelper is a
Singleton class which provides:

  1. Random non-Drupal scalar values generation.
  2. Static non-Drupal scalar values generation.
  3. Random asset generator (files of different types).
  4. Static asset generator (files from pre-defined assets).
  5. Random Drupal entity values generation.
  6. Static Drupal entity values generation.

Random vs Static content

Sometimes, it is sufficient to simply populate entities with random
content to make the site look "not empty". Depending on your deployment
strategy (if you are enabling content generation modules on every
deployment on top of the fresh database), this may change the content on
every deployment.

However, there are times when all generated content can still be a
"placeholder" content, but it should be "static" between deployments, so
that all content and it's aliases would not change. This is specifically
important for Visual Regression testing during a release: the tool can
compare generated pages with known aliases in 2 environments and report
differences, if any.

Activity

Total releases
4
First release
May 2025
Latest release
1 week ago
Releases (12 mo)
3 ▲ from 1
Maintenance
Active

Release Timeline

Releases

Version Type Release date
2.1.0 Stable Jul 10, 2026
2.0.1 Stable Jun 13, 2026
2.0.0 Stable Mar 17, 2026
1.5.4 Stable May 13, 2025