Is there any programming method to hide or show each Field's Label of custom content type in twig template files, regardless of fields manage display setting?

2 Answers 2


Heres a little twig filter module that does just that: https://www.drupal.org/project/twig_field_value. If you study the code you can see how the filter works and deduce how it works programatically.


Override the template for that specific field and don't print the label.


{% if multiple %}
  <div{{ attributes }}>
    {% for item in items %}
      <div{{ item.attributes }}>{{ item.content }}</div>
    {% endfor %}
{% else %}
  {% for item in items %}
    <div{{ attributes }}>{{ item.content }}</div>
  {% endfor %}
{% endif %}

Alternatively, you can preprocess the field and remove the label/change the display, but personally I would do it in the templates so later on the label could easily be added back in.

  • I think it is best to give a code example...
    – user16289
    Aug 17, 2016 at 20:25
  • code example has been added Sep 14, 2021 at 17:46

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.