Recipes in Drupal 12: what is in core and how to apply them

Building

Recipes are not new in Drupal 12 – they arrived during the Drupal 10 cycle – but in Drupal 12 they have taken over more of the job that install profiles used to do. The Standard installation is itself a recipe that pulls in smaller recipes, and the Article and Basic page content types that used to come with it are gone. Knowing what the core recipes do, and how to apply one, is part of building any Drupal 12 site.

What a recipe is

A recipe is a folder with a recipe.yml file and, optionally, a config folder and a content folder. When you apply it, Drupal installs the modules and themes it lists, imports its configuration, runs its config actions (small changes to existing configuration, such as granting a permission) and creates its content. A recipe can include other recipes.

Unlike a module, a recipe leaves nothing behind: once it has been applied, the site owns the configuration, and there is nothing to uninstall. Applying a recipe is a one-off action.

The 21 recipes in Drupal 12 core

These are the folders in core/recipes in Drupal 12.0.0-rc1, with core's own descriptions shortened:

RecipeWhat it does
standardA standard site with commonly used features. Uses most of the recipes below.
administrator_roleThe Administrator role.
content_editor_roleThe Content editor role.
core_recommended_admin_themeSets Default Admin as the admin theme.
core_recommended_maintenanceAutomated Cron, Announcements, Database logging and Views.
core_recommended_performancePage Cache, Dynamic Page Cache and BigPipe.
basic_block_typeA "Basic block" block type with a body.
basic_html_format_editorThe Basic HTML text format with CKEditor 5.
full_html_format_editorThe Full HTML text format with CKEditor 5.
restricted_html_formatThe Restricted HTML text format (no editor).
comment_baseCommenting on content.
editorial_workflowAn editorial workflow for moderating content (Content Moderation).
tags_taxonomyThe Tags vocabulary.
user_picturePictures (avatars) on user accounts.
image_media_typeAn Image media type.
document_media_typeA Document media type, for files such as PDFs.
audio_media_typeAn Audio media type for local audio files.
local_video_media_typeA media type for self-hosted video files.
remote_video_media_typeA media type for videos on YouTube and Vimeo.
standard_responsive_imagesBasic responsive images and image styles.
exampleA commented example that shows the recipe format.

Two recipes from Drupal 11 are gone: basic_shortcuts (the Shortcut module has left core) and core_recommended_front_end_theme (Olivero has left core). The content type recipes page_content_type and article_content_type were already removed in Drupal 11.4.

See what a recipe does before you apply it

vendor/bin/dr recipe:info core/recipes/tags_taxonomy

This prints the description and any inputs the recipe asks for. Better still, read its recipe.yml – it is short.

Apply a recipe

With core's own command (run from the project root):

vendor/bin/dr recipe:apply core/recipes/image_media_type

Or with Drush:

vendor/bin/drush recipe:apply core/recipes/image_media_type

The path is relative to the web root (web/). Recipes that ask for input, for example a site name or an email address, take it with --input=RECIPE_NAME.INPUT_NAME=VALUE. Afterwards, rebuild caches and export your configuration, so that the result ends up in config/sync like every other change.

Contributed recipes are installed with Composer like modules (composer require). The drupal/core-recipe-unpack plugin that comes with the project template then "unpacks" the recipe: it moves the recipe's own Composer requirements into your composer.json and removes the recipe itself as a dependency, because a recipe has no code that needs to stay installed.

What recipe.yml looks like

This is a shortened version of core's example recipe:

name: 'Example'
description: 'Provides an example recipe.'
type: 'Content type'
install:
  - node
  - text
config:
  import:
    text:
      - text.settings
    node: '*'
  actions:
    text.settings:
      simpleConfigUpdate:
        default_summary_length: 700
  • recipes: (not in this example) lists other recipes to apply first.
  • install: lists modules and themes. Only their simple configuration is installed, so the recipe stays in control.
  • config: import: picks configuration that the modules ship, either named items or '*' for all of it.
  • config: actions: changes configuration that already exists – here a setting; elsewhere a permission (grantPermission) or the default theme.
  • config: strict: decides whether existing configuration that differs from the recipe's is an error (true) or is left alone (false).

A recipe for your own content types

Since core no longer has Article and Basic page, a small recipe of your own is a good way to keep the content model of several sites the same. Create the content type once in the admin, export its configuration (the node type, the field storages and fields, the form and view displays) into a recipe's config folder, and list node, text and the other modules it needs under install:. See Content types in Drupal 12 for what to create.