Where to find Drupal 8 Views Theme Information. Err, You can’t. Twig Debug Instead!

The handy “Theming information” window available in Drupal 7 which more or less told you what template file name to use for theming Views has been removed in D8. I have yet to see an argument for why this was done, but alas it’s been left out in D8 core Views.

What has replaced this as the suggested new approach is combing the view front end page source to find template hints by enabling “Twig Debug Mode”.

Enabling Twig Debug Mode in Drupal 8.4, locally only.

Twig debug mode can be enabled in the services.yml file sites/default/services.yml as this Drupal.org page on Debugging twig templates would suggest but if you are working locally, using Git to push to staging and live you probably don’t want to push this configuration to a production server.
You may already have a local settings file set up, if so you can skip to step 3.
In order to have configuration that only applies locally:

  1. Copy sites/default/exmaple.settings.local.php to sites/default/settings.local.php
  2. Uncomment the following in sites/default/settings.local.php this will also enable the sites/default/development.services.yml file
    $local_settings = __DIR__ . "/settings.local.php";
    if (file_exists($local_settings)) {
        include $local_settings;
  3. Edit sites/default/development.services.yml by adding the settings below to “parameters:”. An explanation of what these do is written in sites/default/development.services.yml
    http.response.debug_cacheability_headers: true
      debug: true
      auto_reload: true
      cache: false
      # for more info https://www.drupal.org/node/2598914
        class: Drupal\Core\Cache\NullBackendFactory

If they aren’t already exclude your settings.local.php and development.services.yml from Git.

Enabling Twig Debug on Pantheon Hosted Drupal 8 Sites

Following the Drupal.org documentation on enabling local configuration does’nt work for sites in the Pantheon workflow. The principle is the same, except edit the services.pantheon.preproduction.yml instead, more on local service configuration from Pantheon here.

More from Pantheon on Environment-Specific Configuration here


$ drush cr

and check the sauce and you should see the debug hints

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_field' -->
<!-- BEGIN OUTPUT from 'core/themes/stable/templates/views/views-view-field.html.twig' -->
<a href="/node/1" hreflang="en">Example Property</a>
<!-- END OUTPUT from 'core/themes/stable/templates/views/views-view-field.html.twig' -->

Debug enabled now to disabling the local the cache in drupal 8.4

Once you have tags and start to work on templates you will probably want to disable the cache. This needs to be done in settings.local.php by adding the following to the bottom

$config['system.performance']['css']['preprocess'] = FALSE;
$config['system.performance']['js']['preprocess'] = FALSE;
$settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
$settings['cache']['bins']['page'] = 'cache.backend.null';

This drupal.org page on Disable Drupal 8 caching during development has more detailed information.

Was this article helpful?