On this page
How to Download and Apply Drupal Recipes
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_coreComposer 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:
cdinto your webroot (NOT the project root. The web root is generally./web, but sometimes./public_htmlor other depending on your server).- Run one of the following:
drush recipe [path/to/recipe]eg.drush recipe ../recipes/[recipe-name](requires Drush 13 or later), orphp core/scripts/drupal recipe [path/to/recipe] -veg.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
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion