I'm trying to print out the url path of a node from a referenced entity paragraph field in my twig template however have not had any success so far. I have tried various common twig functions but with no luck.
Any ideas?
I'm trying to print out the url path of a node from a referenced entity paragraph field in my twig template however have not had any success so far. I have tried various common twig functions but with no luck.
Any ideas?
Use the Twig path() function and build a node route with the target id of the reference field:
paragraph.html.twig
{% if paragraph.field_example.target_id %}
<a href="{{ path('entity.node.canonical', {'node': paragraph.field_example.target_id}) }}">{{ 'View node page'|t }}</a>
{% endif %}
See https://www.drupal.org/docs/8/theming/twig/functions-in-twig-templates