Link to node in View with TWIG I have a set of nodes, some of which are just a title, while others have body and other content.

I'm trying to create a view, which lists the node titles. If the body of the node contains content, the title should link to the node, but if the node body is empty, it should just display the title as plain text.

I think I can achieve this by rewriting the title field in the view with TWIG.

I've got it working so it detects the body and displays a link, but I'm not sure what to put for "url" in the link.

{% if body|render|trim is not empty %}
&lt;a href="{{ url }}"&gt;{{ title }}&lt;/a&gt;
{% else %}
{{ title }}
{% endif %}


How can the TWIG code get the url of the node to link to?
In the view fields search for "Link to content", add the field, exclude this from presentation and move it to the top, and now you can use:

{% if body|render|trim is not empty %}
  {{ view_node }}
{% else %}
  {{ title }}
{% endif %}