I'm trying to print out the url path from the title in my twig template however I haven't been successful so far.

Printing out the title containing the link works fine using:


However, I would like to seperate the URL from the title so I can use it in other areas of my twig template. For example:

<a href="{{ content.title.0.url }}">Example text</a>

I've tried various combinations and suggestions from stackexchange/drupal forums but to no avail. e.g. {{ url }}, {{ uri }} etc.

Any ideas?

  • What field type is your title field, is it a link field or a normal plain text field? If it’s a normal text field there's no url.
    – user72672
    May 21, 2019 at 6:49
  • @JDrupal The title comes from the node.
    – Dean
    May 22, 2019 at 2:20
  • I am using paragraphs with an entity reference field called "field_nodes"
    – Dean
    May 22, 2019 at 2:21

1 Answer 1


If the content that you refer to is a node then you can use the twig path function as follows:

<a href="{{ path('entity.node.canonical', {'node': content.id}) }}">{{ 'Example text'|t }}</a>
  • Thanks Maria. It doesn't appear to be working for my case. I have added more details in the comments section above.
    – Dean
    May 22, 2019 at 2:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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