Drupal 11: Turn On Twig Development Mode Via Drush

These three Drush commands will turn on the Twig debugging output, disable the Twig cache, and disable the Twig cache.

drush state:set twig_debug 1
drush state:set twig_cache_disable 1
drush state:set disable_rendered_output_cache_bins 1

Doing this makes theme development much easier as it will prevent Twig templates from being cached and also add HTML comments to your theme to show what templates are being used.

Just remember to turn these settings off in production!

Comments

Hey Phil, does this still work in Drupal 11.3? It seems that this one has no impact. E.g. when I run drush state:set twig_debug 1 I can not see debug output and the related checkbox under /admin/config/development/settings is still unchecked.

The fairly `drush theme:dev on` does work, btw. Maybe something has changed lately.

Philipp

Hi Philipp!

You are right, I think the internal storage of those variables must have changed. They used to be stored in the state API, but they are now stored in the key/value store, which doesn't have a Drush interface so there's no way of setting them.

So, yes, this changes things a bit.

To turn on the dev settings run the following

drush theme:dev on

To turn them off again.

drush theme:dev off

These commands were introduced in Drush 13.6.

Phil Norton

philipnorton42

Add new comment

The content of this field is kept private and will not be shown publicly.