Search code examples
drupal-7twig

How to display the content.field_xxx in twig (Drupal 7)


I have added a custom field field_instruction (plain text field) in a new content type.

I would like to display the field like {{ content.field_instruction }} in node.html.twig. However, it failed.

I tried {{ content.field_instruction[0] }} or {{ content.field_instruction.value }}, it does not success.

Can anyone advise me how to display this field?


Solution

  • To render a field's default value inside node.html.twig, try use a Twig variable as in {{ node.field_some_name.value }}.