First I disable view for taxonomy-term, so I can use taxonomy-term--drzava.html.twig, where drzava is name of vocabulary.

How to print description and filed value for taxonomy-term directly, without using


{{ content.description }} or {{ content.field_flag_code}}

I have problem to analyze devel output. I try {{ content.description.value }} but its do not work.

and for field, I try something like this but its do not work. {{ content.field_flag_code.0.value }}

In Devel there is Definition, Render and Load, what from this tri tabs I need to look for twig?

Thanks for the help in advance.

enter image description here

2 Answers 2


The description field is a formatted text field which should be printed as processed text render element:


{{ {
  '#type': 'processed_text',
  '#text': term.description.value,
  '#format': term.description.format,
} }}

If you want to get rid of the <p> tag you have to configure the field with a a different text format or use |render|striptags on a variable stored like in the linked topic.

The other field value:

{{ term.field_flag_code.0.value }}
  • Thank you a lot. I learn one very nice staf. prnt.sc/26ja49b I edit a litle your answer
    – SakaSerbia
    Commented Jan 25, 2022 at 20:43
  • About your edit, the other field doesn't seem to be a formatted text field.
    – 4uk4
    Commented Jan 25, 2022 at 20:52
  • I was plane to use field_flag_code field as css marker. <span class="flag-50 flag-icon flag-icon-en flag-icon-squared "> like flag-icon-{{ term.field_flag_code.0.value }} . I was use the some method and its work. :)
    – SakaSerbia
    Commented Jan 25, 2022 at 20:57

I remembered. I hadn't used drupal for a while, so I forgot.

I use Devel:

{{ kint(content.description['#items'].getValue()|first.value) }}

and in taxonomy-term--drzava.html.twig, I Use

{{ content.description['#items'].value }}

enter image description here

This is my output. But I don't understand why its display <P></P>

  • 1
    <p> tags are probably being added because the description is passed through an input filter, which adds the tags automatically. If you want to get rid of them, use striptags: twig.symfony.com/doc/2.x/filters/striptags.html Commented Jan 25, 2022 at 3:06
  • 1
    Yes, this is clear in the debug output because the field has a property format. The correct way is then to output it as processed_text to apply the output filters of the text format, too. See drupal.stackexchange.com/questions/238762/…. This link is for a node, in a taxonomy term template use term.
    – 4uk4
    Commented Jan 25, 2022 at 14:53
  • @4k4 This is very nice solution. Where to put '#test' => $term in some preprocess functions or..? I always afraid to write preprocess functions.
    – SakaSerbia
    Commented Jan 25, 2022 at 19:46
  • 1
    You don't need a preprocess hook because the variable term is already available, see the documentation at the top of template. I post a code example as answer.
    – 4uk4
    Commented Jan 25, 2022 at 20:28

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.