Drupal 8 Theming – Part 02 – Disable Cache, Enable Twig Debug

Drupal tutorials webdesign videos
Lightning fast hosting for a shockingly low price! 50% off GoDaddy Hosting plans

In this episode of Drupal 8 Theming we are going to learn how to disable Drupal 8 cache and enable Twig debug mode so that we can develop our theme without having to clear the cache all the time.

This all sounds very simple but as you will see in this video it’s actually very convoluted if you want to do it the right way.

I will show you how to disable cache for Drupal 8 in your development environment so that you can easily disable it once the site goes live. Because of course you want all of that cache goodness for your production environment as it will make your site much faster.

You will also learn how to enable twig debug – one of the Drupal 8 killer features that will help us develop our theme by giving us helpful information about our templates, suggest template names and show us what information from the system we have available on the current page. All good stuff.



21 thoughts on “Drupal 8 Theming – Part 02 – Disable Cache, Enable Twig Debug”

  1. For those who are struggling for configuring caching for Drupal 8.4.4
    – Just copy the example.settings.local.php which is located outside of the files folder into files folder with settings.local.php
    – uncomment $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
    – Again, uncomment $settings['cache']['bins']['page'] = 'cache.backend.null';
    It will work perfectly fine wether you are logged on or logged off

  2. Hi, Thank you for this wonderful tutorial however, I have some issues on my Drupal project. I named my front page as page.html.twig and it's working fine AND naming the template(for other pages) html–node–%.html.twig [as per suggestion] also works BUT css and js are not loaded. I hope you understand what I am saying. Help is much appreciated.

  3. Ivan, this is fantastic! I have already done 3 other "Theming with Drupal 8" tutorials, and they basically all ended where your second video ends. I am extremely happy to see that you have so much more content to go. I am Brand-new to Drupal and you have turned a nightmare of finding adequate help in Drupal 8 theming, into a dream!!!! Thank you!

  4. In drupal8.5 it all seems a lot easier. By just copying the default.services.yml to services.yml and turn on the twig:debug, the auto reload is automatically turned on. So that saves going through all the steps explained in this video. Thank goodness, because it is a great video but a hassle for all these steps.

  5. 11:04 Be careful here. In later Drupal (e.g. 8.4.0) there is already a "parameters" section in sitesdevelopment.services.yml, so the 4 new lines have to go in there, above the "services" section.

  6. 08:05 I couldn't save the file (Windows 10, Drupal 8.4.0). The attributes on the file were ra—–. I attempted to change through file Properties > Security but failed, despite being the admin of my PC. Finally pasted the contents into a new file on another drive, renamed it to settings.php, then was able to drag it to overwrite the original sites/default/settings.php. The attributes on the file are now -a—–. Not sure why I couldn't save that file and it seems everyone else can. I guess it might be a security risk if I forget to change it back on the production site?

  7. And Drupal 8 is supposed to be more efficient how? Sorry, but much like the abortion that is Commerce, it seems that 8 is frankly not worth the time nor the effort. We'll run 7 until it dies and bid our ado to Drupal. The last thing we want is our customers going to WP and I'm pretty certain that this will drive them straight to it. Good on you Ivan for going through this mess and trying to help others begin to understand it. You have my utmost respect sir!

Leave a Reply

Your email address will not be published. Required fields are marked *