In Backdrop CMS and in Drupal CMS, modules and recipes serve different purposes but both help extend and configure a site efficiently. Here's how they differ:
A Module
- Definition: A module is a package of PHP, YAML, and other assets that adds new features or alters existing functionality in a CMS.
- Functionality: Can provide new content types, blocks, fields, permissions, integrations with third-party services, and more.
- Types:
- Core modules built into CMS (Backdrop / Drupal), like Views or CKEditor
- Contributed modules (available on BackdropCMS or Drupal.org, like Webform or BackupAndMigrate)
- Custom modules (developed by site builders for specific needs)
- Installation: Requires enabling through the CMS UI or Drush/Composer.
- Code-based: Developers write PHP code to define functionality.
A Recipe
- Definition: A recipe is a YAML-based configuration package that automates the setup of a site by installing modules, enabling configurations, and even creating content.
- Functionality:
- Bundles together modules, configuration, and content setup.
- Can install multiple modules and apply pre-configured settings automatically.
- Can be reusable and composable, meaning multiple recipes can be applied to the same site.
- Types:
- Base Recipes: Define a fundamental site setup.
- Feature Recipes: Add specific functionality like media management or SEO tools.
- Configuration-based: Uses YAML files rather than PHP code.
Key Differences
Feature | Module | Recipe |
---|---|---|
Purpose | Adds new functionality via PHP code | Automates site setup with predefined modules & configs |
Code Type | PHP, YAML, and sometimes JavaScript | YAML only |
Scope | Can introduce new functionality and APIs | Focuses on installing and configuring existing functionality |
Installation | Enabled via UI or Drush/Composer | Applied via Drush or installation profile |
Reusability | Requires enabling individual modules and configuring them manually | Can bundle multiple modules & configurations for easy reuse |
Example | Pathauto module (provides automatic URL aliases) | SEO recipe (installs Pathauto, Metatag, XML Sitemap, and preconfigures them) |
When to Use What?
- Use a module when you need to add new functionality to CMS.
- Use a recipe when you need to streamline site setup with a pre-configured collection of modules and settings.
Would you like a deeper dive into how recipes work in a migration from Drupal 7 to Backdrop CMS? Connect with us for more info.