PHPackages                             drupal/default\_content - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. drupal/default\_content

ActiveDrupal-module[Utility &amp; Helpers](/categories/utility)

drupal/default\_content
=======================

Imports default content when a module is enabled

4323.9k20[13 issues](https://github.com/larowlan/default_content/issues)[2 PRs](https://github.com/larowlan/default_content/pulls)20PHP

Since Nov 4Pushed 6y ago15 watchersCompare

[ Source](https://github.com/larowlan/default_content)[ Packagist](https://packagist.org/packages/drupal/default_content)[ RSS](/packages/drupal-default-content/feed)WikiDiscussions 8.x-1.x Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (20)

Default Content
===============

[](#default-content)

CONTENTS OF THIS FILE
---------------------

[](#contents-of-this-file)

---

- Introduction
- Requirements
- Installation
- Configuration
- Usage

Introduction
------------

[](#introduction)

*A default content solution for Drupal 8*

[Default Content](https://www.drupal.org/project/default_content "Default Content") allows you to export content along with site configuration information. It does so by leveraging core's serialization and hal modules. It supports entity-references between content as well as files if you have File entity. Content export works with a set of drush commands (more on those below). Content import happens automatically as part of site installation. The import process scans all modules and imports any content found that is located in the expected file path and using the expected .json file structure. (See detailed information below)

### Features

[](#features)

- Supports entity-references between content
- Supports files if you have File entity
- Easily export your content and its dependencies to yml using drush commands

### Additional Information

[](#additional-information)

- For a full description of the module, visit the project page: [https://www.drupal.org/project/default\_content](https://www.drupal.org/project/default_content)
- To submit bug reports and feature suggestions, or to track changes: [https://www.drupal.org/project/issues/default\_content](https://www.drupal.org/project/issues/default_content)

Requirements
------------

[](#requirements)

- Drupal 8
- core only
    - [HAL (Hypertext Application Language) module](https://www.drupal.org/docs/8/core/modules/hal "HAL (Hypertext Application Language) module") must be enabled
    - [Serialization module](https://www.drupal.org/docs/8/core/modules/serialization "Serialization module") must be enabled

Installation
------------

[](#installation)

Install as you would normally install a contributed Drupal module. Visit: for further information.

Configuration
-------------

[](#configuration)

The module has no menu or modifiable settings. There is no configuration. When the default\_content module is enabled, the core HAL and Serialization modules must also be enabled. If they are currently disabled, activating default\_content will give you the option to enable them.

Usage
-----

[](#usage)

For any module that requires default content, the export process is as follows:

1. Generate a hal+json file for each entity to be exported using the drush commands described below.
2. The entity .json files must be stored in module subdirectories using the following structure: `content/{entity type}/{filename}`, where `{entity type}` will be one of node, taxonomy\_term, etc. Filename should be `{entity ID}.json`. For example, a Basic Page with the node ID of 23 would be stored in: `.../modules/custom/someCustomModule/node/23.json`

Other examples:

- `modules/default_content_test/content`
- `modules/default_content_test/content/node`
- `modules/default_content_test/content/node/imported.json`
- `modules/default_content_test/content/taxonomy_term`
- `modules/default_content_test/content/taxonomy_term/tag.json`

3. Once your custom module is enabled, the entities you exported will be imported to the new environment during new site installation.

### Note

[](#note)

At the moment these files need to be hand-created or exported using the Rest, Hal and Serialization modules. Note that the default functionality of the Hal module is to make all links point to the origin site's FDQN.

The default\_content module expects these (at this stage) to be relative to  as there is no point in having default content that can only be re-imported on the originating site.

Note that imported.json contains a node with a term reference field that includes a reference to the term in tag.json.

The Gliph library (in 8.x core) is used to resolve the dependency graph, so in this case the term is imported first so that the reference to it is created in the node.

### Drush Commands

[](#drush-commands)

#### Exports a single entity

[](#exports-a-single-entity)

##### default-content-export

[](#default-content-export)

Arguments:

- **entity\_type:** The entity type to export.
- **entity\_id:** The ID of the entity to export. options:
- **file:** Write out the exported content to a file instead of stdout aliases: dce
- **required-arguments:** 2

Example:

```
$ drush dce node 123 my_default_content_module

```

Change the entity type, as we have them in the system.

```
$ drush dce node  my_default_content_module
$ drush dce taxonomy_term  my_default_content_module
$ drush dce file  my_default_content_module
$ drush dce media  my_default_content_module
$ drush dce menu_link_content  my_default_content_module
$ drush dce block_content  my_default_content_module

```

#### Exports an entity and all its referenced entities

[](#exports-an-entity-and-all-its-referenced-entities)

##### default-content-export-references

[](#default-content-export-references)

Arguments:

- **entity\_type:** The entity type to export.
- **entity\_id:** The ID of the entity to export. options:
- **folder:** Folder to export to, entities are grouped by entity type into directories. aliases: dcer
- **required-arguments:** 1

Example:

```
$ drush dcer node 123 my_default_content_module

```

#### Exports all content defined in a module info file.

[](#exports-all-content-defined-in-a-module-info-file)

##### default-content-export-module

[](#default-content-export-module)

Arguments:

- module: The name of the module.
- aliases: dcem
- required-arguments: 1

Example:

```
$ drush dcem my_default_content_module

```

And add the UUID of entities in my\_default\_content\_module.info.yml file.

```
default_content:
  node:
    - c9a89616-7057-4971-8337-555e425ed782
    - b6d6d9fd-4f28-4918-b100-ffcfb15c9374
  file:
    - 59674274-f1f5-4d6a-be00-fecedfde6534
    - 0fab901d-36ba-4bfd-9b00-d6617ffc2f1f
  media:
    - ee63912a-6276-4081-93af-63ca66285594
    - bcb3c719-e266-45c1-8b90-8f630f86dcc7
  menu_link_content:
    - 9fbb684c-156d-49d6-b24b-755501b434e6
    - 19f38567-4051-4682-bf00-a4f19de48a01
  block_content:
    - af171e09-fcb2-4d93-a94d-77dc61aab213
    - a608987c-1b74-442b-b900-a54f40cda661

```

To do
-----

[](#to-do)

UI for easily exporting?

[![Build Status](https://camo.githubusercontent.com/a6445b12fc766ecc19a922b9342c1dc5a275de698af28872d14d09d5614b24a6/68747470733a2f2f7472617669732d63692e6f72672f6c61726f776c616e2f64656661756c745f636f6e74656e742e7376673f6272616e63683d382e782d312e78)](https://travis-ci.org/larowlan/default_content)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance14

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community40

Growing community involvement

Maturity43

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/00a3eaecefc3980ee1877dbbbfa1c8a21161730af8227bbc2a8c120eb77e94a5?d=identicon)[larowlan](/maintainers/larowlan)

---

Top Contributors

[![larowlan](https://avatars.githubusercontent.com/u/555254?v=4)](https://github.com/larowlan "larowlan (44 commits)")[![Berdir](https://avatars.githubusercontent.com/u/40826?v=4)](https://github.com/Berdir "Berdir (15 commits)")[![andypost](https://avatars.githubusercontent.com/u/73713?v=4)](https://github.com/andypost "andypost (8 commits)")[![dawehner](https://avatars.githubusercontent.com/u/29678?v=4)](https://github.com/dawehner "dawehner (8 commits)")[![jibran](https://avatars.githubusercontent.com/u/2111106?v=4)](https://github.com/jibran "jibran (5 commits)")[![matslats](https://avatars.githubusercontent.com/u/1170956?v=4)](https://github.com/matslats "matslats (5 commits)")[![benjy](https://avatars.githubusercontent.com/u/863137?v=4)](https://github.com/benjy "benjy (3 commits)")[![LKS90](https://avatars.githubusercontent.com/u/11182340?v=4)](https://github.com/LKS90 "LKS90 (3 commits)")[![mbovan](https://avatars.githubusercontent.com/u/1346724?v=4)](https://github.com/mbovan "mbovan (1 commits)")[![taz77](https://avatars.githubusercontent.com/u/1389543?v=4)](https://github.com/taz77 "taz77 (1 commits)")

### Embed Badge

![Health badge](/badges/drupal-default-content/health.svg)

```
[![Health](https://phpackages.com/badges/drupal-default-content/health.svg)](https://phpackages.com/packages/drupal-default-content)
```

###  Alternatives

[hanneskod/classtools

Find, extract and process classes from file system

1319.1M40](/packages/hanneskod-classtools)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
