New in Drupal: Assemble Any Website Functionality Easily With Recipes!

Oct 11 2023

Authored by: Nadiia Nykolaichuk

If someone said “There’s no easy recipe for a perfect website,” we’d have to argue with that statement. Even more so now that Drupal is bringing a new, exciting concept of Recipes on stage. Recipes are currently in the making, but they have already become the talk of the town as one of the most powerful additions to the CMS on the way from Drupal 10 to Drupal 11.

What are Drupal Recipes?

Recipes are a new concept in Drupal that enables site builders and developers to assemble Drupal functionality from predefined packages quickly and easily. This can be helpful in jumpstarting a new website or adding smaller features such as content types, image styles, user roles, and so on. One of the major use cases for Recipes is when you need to compose feature sets for specific types of websites (a blog, a non-profit website, a higher-ed website, etc.). 

The new concept of would-be Recipes was introduced by Drupal founder Dries Buytaert at his DrupalCon Portland 2022 Driesnote where he called them “Starter templates.” To provide some examples, Dries mentioned a template of a product site that could include a carousel, a web form for requesting a demo, a bunch of content types, etc. Another example was an event website that would allow users to easily put together a program, create speaker bios, and more. Dries also showed a demo of how users should eventually be able to browse for starter templates on drupal.org.

A demo shared by Dries Buytaert of browsing for starter templates.
A demo shared by Dries Buytaert of browsing for starter templates.

Currently, these kinds of templates are referred to as Recipes and are backed by a special Drupal strategic initiative, which is in full swing. There is also a contributed project page to check out. 

Recipes: “Standing on the shoulders” of Drupal distributions

If the idea of using a predefined package to jumpstart a website sounds extremely familiar to you, you’re absolutely right. Indeed, for many years, Drupal has been using the concept of distributions for that purpose. Distributions contain the Drupal core, as well as a set of contributed modules, themes, libraries, and configurations for a specific type of website in a single download.

“Obviously, nothing in Drupal is a green field. The Drupal Recipes Initiative is standing on the shoulders of giants.” Alex Pott, a top Drupal core committer and one of the Recipes Initiative leads, said at his DrupalCon Prague speech. Referring to giants, he mentioned a couple of well-known Drupal distributions from the entire history of the CMS — DeanSpace (later renamed to CivicSpace), OpenAtrium, Panopoly, Lightning, Thunder, and Commerce Kickstart. 

However, distributions weren’t delivering what was expected from them, and something needed to change, said Alex. So the creators of Recipes are learning all the lessons from Drupal distributions to make things better. We can see that the full name of the new strategic initiative is “Distributions and Recipes.”

So what exactly was wrong with Drupal distributions? 

  • Discussing the pitfalls of distributions, Alex mentioned that they are hard to create, maintain, and share. Their maintainers have to constantly make sure they are up to date with the latest API changes in Drupal and take care of all the dependencies.
  • Furthermore, distributions lack flexibility and bind websites with their own “rules of the game” from the day they are installed and forever. Quoting Alex Pott, they are “kind of responsible for the entire site — when you install a distribution, it’s responsible for what themes you’re choosing at the start, it’s taking over all of your configuration, and you just can’t get out of that.” Indeed, it’s virtually impossible to uninstall a distribution in Drupal. 

 

A slide by Alex Pott about the difficulty of creating and maintaining Drupal distribution.
A slide by Alex Pott about the difficulty of creating and maintaining Drupal distribution.

There also are other solutions overlapping with Recipes to some extent — the Drupal core installation profiles (Standard, Minimal, and Umami), the Features module allowing you to package and export functionality, and custom modules. However, they all present a bunch of complexities as well, so here is where Recipes comes in as a particularly simple and flexible solution.

Some of the benefits of the game-changing Recipes

  • Installable at any time. One of the best benefits of recipes as opposed to distributions is that Recipes be installed at any point in time on your existing website. This should include the option to find and install recipes via the Drupal admin UI using Project Browser — another revolutionary innovation that’s coming to the Drupal core in the near future.
  • Mixable and composable. Next, you can mix and match as many recipes as you like. For example, if you want an LMS system but also need Commerce in it, it’s possible to install recipes for both. Recipes are easily composable with other recipes to create recipe Kits. 
  • Individual components are replaceable. Furthermore, recipes do not lock sites into a monolithic setup like distributions do. Instead, they allow you to replace individual components, so you are not bound to use an entire predefined package — you can use exactly what you need.
  • No need to maintain or update. Recipes are applied to websites, not installed on them, which frees you from the difficulties of maintaining anything. This was mentioned by the Recipes Initiative co-lead, Jim Birch, at DrupalCon Pittsburgh 2023.
A slide by Jim Birch about the benefits of Drupal Recipes.
A slide by Jim Birch about the benefits of Drupal Recipes.

A glimpse of how Drupal Recipes work

To provide more clarity for the above-mentioned “applied, not installed” approach with recipes, it’s important to mention one of their most prominent characteristics — they are all about configuration. As successfully summed up on the Initiative’s page, they are “declarative, not functional.” 

The first thing recipes do is install the respective modules or themes for the required functionality. After that, you can create or update the configuration, explained Jim in the above-mentioned DrupalCon session. For example, if you want to have the Metatag module, you install the recipe for it, which comes with 5 configuration files, but it’s up to you to change this after the installation. 

Furthermore, recipes can apply to other recipes. For example, you can have a Drupal recipe that does one thing and it can apply to another Drupal recipe that does another thing. Finally, according to Jim, there is also a new idea to eventually make Drupal Recipes able to create content. 

A slide by Jim Birch about how Drupal Recipes work.
A slide by Jim Birch about how Drupal Recipes work.

It’s noteworthy that recipes can install modules that contain code but they don’t have any code themselves. They don’t make dynamic changes to code-related things, only to configuration. Once you install a Drupal recipe, it’s part of your own configuration, explained Jim. Obviously, they also don’t have an upgrade path since there’s nothing to upgrade.

A slide by Jim Birch about what Drupal Recipes don’t do.
A slide by Jim Birch about what Drupal Recipes don’t do.

A recipe is going to have a folder like a Drupal module, so let’s look at the folder structure for it. It includes a recipe.yml file and a configuration folder where you can keep your configuration files. In Jim’s example below, there is node.type.event.yml file that creates a content type called “Event.”

A slide by Jim Birch about the folder structure of Drupal Recipes.
A slide by Jim Birch about the folder structure of Drupal Recipes.

Let’s dig a little deeper and look inside the recipe.yml file structure:

  • It defines the recipe’s name (in this example, “Event”) and type (in this example, “Content type”). 
  • It specifies whether the current recipe looks for other recipes. In this example, it looks for the “Event manager” recipe, which creates a user role with this name on the Drupal website and lies in the same folder as the “Event” recipe. 
  • Next, the recipe installs the necessary modules if those are not yet installed on the website. In this case, it installs the Datetime range and the Node modules. 
  • Finally, there are Config Actions, which Jim called the magic of Drupal Recipes. This powerful feature is useful for altering an existing configuration. In this example, config actions go into an existing “user.role.event_manager” configuration and alter it by granting the permissions to edit and delete any event content. 

Using the approach described in the above steps, it’s possible to create an entire “Event” system with a bunch of little recipes for various purposes aggregated into one larger recipe. 

A slide by Jim Birch about the recipe.yml file structure.
A slide by Jim Birch about the recipe.yml file structure.

Final thoughts

It looks like Drupal has found a reliable recipe for becoming a CMS that empowers everyone to build amazing things on websites quickly and easily. It infallibly follows this path, offering remarkable improvements like Recipes and many others. 

While still in the making, Drupal Recipes are waiting for their golden era. They should appear in one of the next Drupal releases, so it’s just a matter of keeping your website updated to benefit from Recipes or other innovations. In the meantime, we could offer you a super quick “recipe” to effortlessly create the desired functionality on your website or do a seamless upgrade — just contact an experienced Drupal partner.

Learn from us
Sign up and receive our monthly insights directly in your inbox!

Subcribe to newsletter (no spam)

Fields