How to Download and Apply Drupal Recipes

Last updated on
1 July 2025

This documentation needs work. See "Help improve this page" in the sidebar.

Add a recipe to the codebase

Drupal recipes should be added to a codebase using Composer, the same as any Drupal module or theme. Using Composer ensures that all dependencies of the recipe, such as supporting modules, are also retrieved. For example, add the User Privacy Core recipe as follows:

composer require drupal/user_privacy_core

Composer will download Drupal recipes into the /vendor directory by default. An emerging convention for locating Drupal recipes is in the /recipes directory. To configure Composer to download Drupal recipes to this directory, run the following commands in your project root (where composer.json is located):

composer config allow-plugins.drupal/core-recipe-unpack true
composer require drupal/core-recipe-unpack
composer require composer/installers:^2.3
composer config --merge --json extra.installer-paths '{"recipes/{$name}":["type:drupal-recipe"]}'

 If you started your project on Drupal 11.2 or later, this is already done for you.

Apply a recipe to a site

Recipes differ from modules and themes: they are not installed/uninstalled, but rather applied, once, into site configuration. Recipes can be applied with either Drush, or a core Drupal script. Apply a recipe as follows:

  1. cd into your webroot (NOT the project root. The web root is generally ./web, but sometimes ./public_html or other depending on your server).
  2. Run one of the following:
    1. drush recipe [path/to/recipe] eg. drush recipe ../recipes/[recipe-name] (requires Drush 13 or later), or
    2. php core/scripts/drupal recipe [path/to/recipe] -v eg. php core/scripts/drupal recipe ../recipes/[recipe-name] -v

The result of the command will vary depending on the recipe. It may install Drupal modules or themes, create content types or Views, and introduce other various site configuration changes. In the case of the previously referenced User Privacy Core recipe, it performs the following actions, as can be seen in its recipe.yml file:

  • Installs the Drupal core recipe "administrator role"
  • Install the contributed module "View Usernames"
  • Grants the "view usernames" permission to the "Administrator" role

Example recipe.yml file:

name: 'User Privacy Core'
description: 'Configures user privacy settings to restrict username visibility to administrators'
type: 'Privacy'

recipes:
  - core/recipes/administrator_role

install:
  - view_usernames

config:
  actions:
    user.role.administrator:
      grantPermissions:
        - 'view usernames'

Help improve this page

Page status: Needs work

You can: