I'm trying to output paragraph field values in a sample paragraph template, but it does not work. I created a twig template in paragraph/paragraph--article--default.html.twig

I have a field called field_action and I tried:

{% block paragraph %}
    <div{{ attributes.addClass(classes) }}>
      {% block content %}

      {% endblock %}
{% endblock paragraph %}

Nothing happens.

If I write {{content}} everything is fine, but I would like to customize output.

Thanks all


  • 1
    Is the block content necessary? Otherwise this should work fine. – Kevin Jan 17 at 16:12

To print out single fields I usually use, {{ paragraph.field_action.value }}.

That should also work for you.

UPDATE: The reason why you had to use {{ paragraph.field_action.entity.field.value }} is because field_action is a entity reference field, and that is the syntax of getting a field value from an entity reference field.

  • I tried to remove block content and to add {{paragraph.field_action.value}} but nothing is working... :( {% block paragraph %} <div{{ attributes.addClass(classes) }}> {{content.field_action}} </div> allo {{paragraph.field_action[0]}} {% endblock paragraph %} – Alexander Jan 17 at 16:15
  • Try to enable devel and kint and then kint paragraph variable. – Jdrupal Jan 17 at 16:16
  • Do you see your field? – Jdrupal Jan 17 at 16:16
  • Okay, I think I understand my mistake. Indeed, there is a paragraph called "article" in which I try to render a node entity. So, I would like to get the field_action from the node. I tried {{kint(paragraph.field_article.field_action)}} but this does not work. – Alexander Jan 17 at 16:34
  • Okay, I found the solution: {{paragraph.field_article.entity.field_action.value}} ! Thnks all! – Alexander Jan 17 at 16:38

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.