Enable Theme Debugging on Development Sites

Theme debugging is a little more tricky because it's a service. Luckily, the example.settings.local.php file tells us how to enable local development services.

If we open up that example file, near the top, you'll see the "Enable local development services" section. As you can see it's looking for a file at "/sites/development.services.yml". That file already exists, so we can just copy this line into our settings.local.php file and add our configuration to the development.services.yml file.

Copy the following to the settings.local.php file

/**
 * Enable local development services.
 */
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';

In order to enable twig debugging, we'll copy just the portions of the services.yml file that we need, so it'll look something like this:

parameters:
  twig.config:
    debug: true

With that done, I'll rebuild the cache, and then, when I refresh the page, you'll see some handy template suggestions in the inspector window.