taxonomy-term.html.twig

Default theme implementation to display a taxonomy term.

Available variables:

  • url: URL of the current term.
  • name: Name of the current term.
  • content: Items for the content of the term (fields and description). Use 'content' to print them all, or print a subset such as 'content.description'. Use the following code to temporarily suppress the printing of a given element:

  {% hide(content.description) %}
  
  • attributes: HTML attributes for the wrapper. The 'class' attribute contains the following classes by default:

    • taxonomy-term: The current template type, i.e. "theming hook".
    • vocabulary-[vocabulary-name]: The vocabulary that this term belongs to. For example, if the term belongs to a vocabulary called "Tags" then the class would be "vocabulary-tags".
  • page: Flag for the full page state.
  • term: The taxonomy term entity, including:
    • id: The ID of the taxonomy term.
  • view_mode: View mode, e.g. 'full', 'teaser', etc.

See also

template_preprocess()

template_preprocess_taxonomy_term()

File

drupal/core/modules/taxonomy/templates/taxonomy-term.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation to display a taxonomy term.
  5. *
  6. * Available variables:
  7. * - url: URL of the current term.
  8. * - name: Name of the current term.
  9. * - content: Items for the content of the term (fields and description).
  10. * Use 'content' to print them all, or print a subset such as
  11. * 'content.description'. Use the following code to temporarily suppress the
  12. * printing of a given element:
  13. * @code
  14. * {% hide(content.description) %}
  15. * @endcode
  16. * - attributes: HTML attributes for the wrapper. The 'class' attribute
  17. * contains the following classes by default:
  18. * - taxonomy-term: The current template type, i.e. "theming hook".
  19. * - vocabulary-[vocabulary-name]: The vocabulary that this term belongs to.
  20. * For example, if the term belongs to a vocabulary called "Tags" then the
  21. * class would be "vocabulary-tags".
  22. * - page: Flag for the full page state.
  23. * - term: The taxonomy term entity, including:
  24. * - id: The ID of the taxonomy term.
  25. * - view_mode: View mode, e.g. 'full', 'teaser', etc.
  26. *
  27. * @see template_preprocess()
  28. * @see template_preprocess_taxonomy_term()
  29. *
  30. * @ingroup themeable
  31. */
  32. #}
  33. <div id="taxonomy-term-{{ term.id }}"{{ attributes }}>
  34. {{ title_prefix }}
  35. {% if not page %}
  36. <h2><a href="{{ url }}">{{ name }}</a></h2>
  37. {% endif %}
  38. {{ title_suffix }}
  39. <div class="content">
  40. {{ content }}
  41. </div>
  42. </div>

Related topics