How to disable Drupal 8 Twig debugging

Twig debugging in Drupal 8 is great — really great — when you need it as you’re developing a new Drupal 8 theme. But when you don’t need it, it generates a lot of extra output in your HTML that gets in the way of working on your theme development.

So, as a quick note to self, to disable (turn off) Drupal 8 Twig debugging, follow these steps:

  • Go to the sites directory
  • Edit the development.services.yml file
  • Set debug to false, as shown here:
parameters:
  twig.config:
    debug: false
    auto_reload: true
    cache: false

Run drush cr after making that change (flush the caches), then reload a page from your website in your browser, look at the HTML source, and you should see the Twig debug output is gone.

For information on enabling Drupal 8 caching during theme development, see this drupal.org URL. That’s where I first learned how to disable caching and put Twig into debug mode.