4

I would like to edit field.html.twig for taxonomy-term.html.twig. I've tried field--taxonomy-term.html.twig and a bunch of other options, none of them seem to work. What is the correct naming convention?

Clarification: I mean the template for fields used on the taxonomy term page, not the fields used in content type to reference a taxonomy.

3

The field type for taxonomy terms is entity-reference. You can use the field type for the naming of the field twig:

field--entity-reference.html.twig

Because there may be more than one reference field, it is more specific to use the field name, for example a twig for the preinstalled tags field:

field--field-tags.html.twig

If you want to use the target entity of a reference field as theme suggestion you would have implement this in a hook.

Edit acc. to the clarification:

If the field is inside of a taxonomy term, you have to add one more detail, either the field name or the name of the vocabulary:

field--taxonomy-term--field-body.html.twig
field--taxonomy-term--tags.html.twig

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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