Accessing subfield data in twig

16 May, 2024

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 }}


  • tip icon. tip
  • D9

    Drupal 9
    Drupal 9


    Drupal 8
    Drupal 8

Login or Register to Comment!