Print node URL in a custom block template I have a custom block that loads multiple nodes from the database and passes it to the twig template.
Inside the template I loop the list printing some node details, but I need to create a link on the node title, possibly its clean (alias) URL. The problem is that with node.url I get a security error:


  Twig_Sandbox_SecurityError: "Calling "url" method on a "Drupal\node\Entity\Node" object is not allowed


I tried with {{ link(item.label, item.url.value) }} but I get the same error.

What is the correct way to create a link in twig using the node URL?
Ok, it seems I have solved the problem using twig/drupal path() function, building the linked title in this way:

&lt;a href="{{ path('entity.node.canonical', {'node': item.id}) }}"&gt;{{ item.label }}&lt;/a&gt;


where "item" is the node object inside the list loop.