2

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

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:

\Drupal\Core\PhpStorage\PhpStorageFactory::get('twig')->deleteAll();

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.

| improve this answer | |
  • Checking the compiled templates did help find some fields. We will use this method moving forwards. – usernameabc Jul 11 '18 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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