Creating Your First Recipe
When to Use
Follow this workflow to create a minimal working recipe from scratch.
Steps: Create and Apply a Minimal Recipe
-
Create recipe directory — Recipes live in discoverable locations
Recipes can be inmkdir -p recipes/my_recipe/recipes/, module subdirectories, or Composer packages. -
Write recipe.yml — Minimum viable recipe
name: 'My Recipe' description: 'Example recipe.' type: 'Feature' install: - node config: strict: false -
Add configuration (optional) — Create
config/directory for config filesmkdir -p recipes/my_recipe/config # Export config from active site drush config:export --destination=recipes/my_recipe/config -
Apply the recipe — Using Drush or core script
# Drush (recommended) drush recipe recipes/my_recipe # Core script (no Drush) php core/scripts/drupal recipe recipes/my_recipe
Decision Points: Config Layout and Strict Mode
| At this step... | If... | Then... |
|---|---|---|
| Adding configuration | Config is simple and static | Use config/ directory for config files |
| Adding configuration | Config needs dynamic updates | Use config.actions for config actions |
| Choosing strict mode | Recipe sets up new functionality | Use strict: false to allow existing config |
| Choosing strict mode | Recipe enforces specific config state | Use strict: true or array of config names to validate |
Common Mistakes
- Applying recipe before installing required modules → Use
install:key to declare dependencies - Putting recipe.yml in wrong location → Must be in recipe root directory, not subdirectory
- Using
config:key without understanding strict mode → Defaults tostrict: truein current core (may change) - Not testing recipe on clean install → Recipes should be idempotent but are designed for apply-once
- Forgetting composer.json for published recipes → Recipes distributed via Composer need
type: drupal-recipe
See Also
- Previous: ← Recipe YAML Schema
- Next: Recipe Composition & Dependencies →
- Reference: https://project.pages.drupalcode.org/distributions_recipes/recipe.html