This 1) Disables the need for you to clear the cache on every page reload after making a change in Twig 2) Enables "Twig debugging", which outputs the the name of the current template (and template suggestions) within HTML comments.
Uncomment the following in settings.php and move it to the bottom of the file.
settings.php
if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {
include $app_root . '/' . $site_path . '/settings.local.php';
}
Copy example.settings.local.php
to settings.local.php
and verify the following lines are uncommented to disable render and local page caches.
settings.local.php
$config['system.performance']['css']['preprocess'] = FALSE;
$config['system.performance']['js']['preprocess'] = FALSE;
Make your development.services.yml
file like below. This file is already enabled within the settings.local.php
that you’ve just enabled.
development.services.yml
# Local development services.
#
# To activate this feature, follow the instructions at the top of the
# 'example.settings.local.php' file, which sits next to this file.
parameters:
http.response.debug_cacheability_headers: true
twig.config:
debug: true
auto_reload: true
cache: false
services:
cache.backend.null:
class: Drupal\Core\Cache\NullBackendFactory