Skip to main content

Book Review: Modernizing Drupal 10 Theme Development

Published on

I just finished reading Modernizing Drupal 10 Theme Development published by Packt Publishing by Luca Lusso. Don't let the title make you think it is about theme development. The book provides excellent coverage of general Drupal knowledge, so much so that I highly recommend this book as a go-to resource for any frontend or full-stack developer new to Drupal. I'd also recommend it for any backend developer working on a large team so that they understand the work their frontend colleagues are performing and how to assist them best.

I enjoyed the flow of the chapters. Reading this book made me think back to when I had my first job building websites, which was primarily front-end development. The book takes you down the journey of a developer tasked to implement a design onto a Drupal site.

There is a starting code base that you clone down and work with throughout the book. This felt natural for how build phases may work: backend developers or site builders scaffold the site, and then it is themed.  

The book begins with onboarding the reader to create a local environment, using the demo code base, some basics of how Drupal works, and how to create a new theme. Then, it dives into styling individual landing pages and components—each step along the way, the book layers in more Drupal knowledge alongside theming implementation.

My favorite highlights from the Modernizing Drupal 10 Theme Development book are:

  • As part of the local development environment setup with DDEV, it provides an excellent introduction for installing and setting up Docker for new users.
  • Creating a new theme using the Starterkit theme and TailwindCSS with Browsersync to provide a streamlined front-end development experience.
  • Introducing BackstopJS for visual regression testing! It is only briefly mentioned, but the example code repository provides the configuration and DDEV custom commands.
  • Learning how to use the WebProfiler module to understand various parts of Drupal's render pipeline and theme information
  • Understanding how to work with component-based design systems using Storybook and integrating them with Twig templates, including the newly added Single Directory Components.
  • Explains using Twig namespace for referencing Twig templates defined by other extensions.
  • Xdebug! The book explains why Xdebug is useful and how to use it in your development flow for theming, including debugging your Twig templates!
  • The book calls out a common mistake when modifying the output of templates: the loss of cacheable metadata bubbling. I was thrilled to see this covered and explain how you may end up with lost cacheable metadata and debugging it.
  • Creating custom Twig functions and filters to abstract away logic from templates into helper methods, keeping templates lean and clean.
  • Using custom entity type bundle classes to encapsulate logic further and remove it from your theming layer. The example given is creating a custom method to abstract away accessing a string value's content.

My only nitpicks are the amount comparisons to Drupal 7. Throughout the book, there are various comparisons to how Drupal 7 did things. I prefer we stop comparing Drupal to its previous iterations, but it may be good that this book does. There may be that frontend developer who worked on Drupal 6 or 7 and rolled their eyes at an upcoming Drupal project. Then, they read this book, which completely changed their mind about frontend development on a Drupal site.

 

Links to products may be Amazon or other affiliate links, which means I will earn a commission if you click through and buy something.

I'm available for one-on-one consulting calls – click here to book a meeting with me 🗓️