
Posted on
Back in December of 2024, I moved this blog back to Drupal, using Drupal CMS for the installation and Tome to export it to static HTML that could be hosted on Github Pages. (It was on Jekyll, which is supported natively by Github Pages.)
I've quite enjoyed the experience of composing blog posts directly within the Drupal user interface again. My process before the migration involved composing my posts in a Google Doc, then using a special plugin to export my content to Markdown, then adding all the media by hand to the Markdown file before committing it to my Github repo. That process made it harder to write a quick post and publish that post in the same day—mostly because the media creation was tedious.
When I moved to Drupal CMS, I picked up a lot of capabilities that make my posts more SEO-friendly, and therefore a bit more AI-friendly, and easier to share on social platforms like LinkedIn. However, it has bothered me a bit that I have a lot of dependencies in my installation that I don't really use right now. As a static site, I don't really need Webform or or Easy Email—even though these are great modules that I use of client projects. I also don't need Drupal CMS Olivero as I created a custom subtheme based on Radix. Drupal CMS is quite opinionated about what a full-featured CMS should include and how to include it. That's what makes it great for demonstration purposes, but it isn't the ideal way to create an maintain an ongoing website.
With the release of Drupal 11.2, the Recipes feature gets an important new capability. You can now "unpack" recipes after they are run so that your composer.json
will have the direct dependencies from the recipe rather than a dependency on the recipe itself. Read more about unpacking recipes in the change record.
Getting started with unpacking recipes
The example below assumes you are adding recipe unpacking to an existing Drupal 11 project.
First, you need to upgrade to Drupal 11.2. This can look different depending on how you initially required Drupal, but a typical command might look like the following:
Update! phenaproxima pointed out in Drupal Slack that there is not a hard requirement of a specific Drupal version that you can use the drupal/core-recipe-unpack
plugin. Technically, you could use this plugin with any Drupal version that supports recipes as early as Drupal 10.3. Though I would probably still recommend updating your instances dependencies for best results with newer recipes.
composer update drupal/core-* --with-all-dependencies
Next, you'll need to require drupal/core-recipe-unpack in your composer.json.
composer require drupal/core-recipe-unpack
Make sure you allow this new plugin in your composer options.
composer config allow-plugins.drupal/core-recipe-unpack true
Finally, you can manually run the unpack command for the first time.
composer drupal:recipe-unpack
That's basically all there is to it. When the command runs, it will look at the recipes you have in your /recipes
directory and unpack them by adding the dependencies within each individual recipe's composer.json
to your project's composer.json
.
Automatic unpacking
While running the unpack process the first time requires manually running the command, any subsequent recipes added through a composer require
command will automatically unpack unless you set some extra configuration.
{
"extra": {
"drupal-recipe-unpack": {
"on-require": false
}
}
}
Note that recipes with dev dependencies in the require-dev
section of your project's composer.json
will not automatically unpack. You'll need to run the unpack command manually in that situation.
I haven't run into any errors with an unpacking command—it was just released today after all—but I can imagine that an existing site with complex version constraints might lead to a bit more finagling to get to a working set of dependencies that will work with the recipe.
Need help unpacking your complex project? Connect with me on LinkedIn or reach out to me on Drupal Slack (@joshuami).