I have three templates

  1. field--field-custom.html.twig
  2. field--field-custom1.html.twig
  3. field--field-image.html.twig

I also have a teaser template containing all three fields like that:

<div{{ content_attributes.addClass('node__content', 'container') }}>
    {{ content }}

I want to have the first two templates in a bootstrap div, for example


and the third template in the other div


If I include the second template in the first template file it just repeats the field instead of rendering the intended field (both templates are name suggestions of the same file). What can I do in order to have both fields in the same template file?


Just chunk the output by using the field names:

<div class=“col-6-sm”>{{ content.field_custom }} {{ content.field_custom1 }}</div>

Then do the same for the remaining field.

  • Awesome! Thank you Kevin. I did it in the node--teaser-* template and just realized, I don't need the field---field-* templates anymore. The first time I tried with the template names, but it refers to the field machine name. – Jorge Montoya Oct 27 '17 at 3:20
<div{{ content_attributes.addClass('node__content', 'container', 'col-sm-6') }}>
    {{ content.field_imagen }}
  <div{{ content_attributes.addClass('node__content', 'container', 'col-sm-6') }}>
    {{ content.field_resumen }}
    {{ content.field_leer_mas }}

Thanks to Kevin!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.