There are times when fields are deleted from a Content type, but there is no way of knowing if there is a related field twig template without manually looking in our repository.

Other than looking for file names, are there any utilities or other methods to find twig templates that are not being used?

2 Answers 2


It's difficult to find a deterministic method, so you probably need some kind of usage statistics.

A simple statistical method would be to clear the twig php cache:


Then run the site for some time and check the twig php cache (/sites/default/files/php/twig) for twig files not having a compiled php template.

  • Checking the compiled templates did help find some fields. We will use this method moving forwards. Commented Jul 11, 2018 at 19:32

You could use drush twig:unused for this:

drush twig:unused --field=template /var/www/project_name/docroot/modules/custom,/var/www/project_name/docroot/themes/custom

Crawl your site first. More information at the drush site here: https://www.drush.org/latest/commands/twig_unused/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.