Main topic described: default configuration
In Drupal 7 default configuration for modules such as content types, field configuration, views, etc. required custom PHP code to install and keep updated. In Drupal 8, these are stored with the configuration system in plain text YAML files.
For example the configuration management system takes care of creating and managing content types. You can ship a content type with your module by creating a properly named and structured configuration file.
Create a file named
node.type.example_mytype.yml and place it in your module's directory in a subdirectory called
config. For example this file could be at
/modules/example/config/node.type.example_mytype.yml if the module is in
Please respect the naming-convention that you prefix your contenttype with your module name followed by an underscore to prevent conflicts with other configuration files.
Then you can place the following code in this file:
description: 'Use <em>example</em> content to get to Drupal 8 development better.'
You can generate these files by manually creating the content type on the site and copying the file from the configuration system's active store to the module directory.
If you intend to manually create this file, enter your own UUID (use an online generator) and you're done.
See node.type.article.yml for a live example.
You can include default configuration for other things like block placement, views, text formats, editor configuration, user roles, etc. with your module the same way.
If you installed the module before adding this content type, you'll need to uninstall and install it again for the configuration to take effect.