I have been working on a D8 project and been wondering what the best course of action would be in order to produce a complete project package that can be easily set up in a new drupal installation. The theme part is pretty straightforward but what about all the specific content types that accompany a project with a specific theme? Is there a way I can have those being created on theme installation?

  • Am not sure if I understand you correctly: are you looking for a deployment solution, or a generic project initialization, which can be easy customized for further projects? (which are similar)
    – ssibal
    Mar 26 '18 at 10:37
  • consider this scenario, you develop a theme locally which is intended for a specific project so many of your templates are specific to content types or views that you have created. Then you have to install that theme on a production server accompanied by the custom content types and so on. I've seen for example a similar functionality with wordpress where you can define custom post types on a theme's functions.php file. Anything similar?
    – Kostas
    Mar 26 '18 at 10:47
  • Related: How do I export my site structure?
    – kenorb
    Apr 10 '18 at 10:42

The best practice for is to use Configuration import/export.

Exporting and importing configuration changes between a Drupal installation in different environments, such as Development, Staging, and Production, allows you to make and verify your changes with a comfortable distance from your site's live environment.


You can add the needed configuration files of the content types and fields needed for the site in a folder named config/install in your theme directory. These configuration gets imported when we install it.

for eg: if you want to create a content type test when your theme is installed

Create a file node.type.test.yml in your_theme/config/install folder paste the code in it

langcode: en
status: true
    - menu_ui
      - main
    parent: 'main:'
name: test
type: test
description: ''
help: ''
new_revision: true
preview_mode: 1
display_submitted: true

Easy method is to

  • create the content types and fields form backend
  • export the configuration
  • Take the newly created files from it and remove the line uuid from it
  • paste it in your theme folder

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.