Accessing subfield data in twig

Tip

You have a compound field with subfields (like the body field) and want to access a subfield in twig? Not a problem.

Let's say your field is field_mystuff and the subfield is url. In twig, you would access it like this:

{{ content.field_mystuff.url }}

 

  • D9
  • D8
  • twig
  • Drupal