What if you have to link to a specific url in in twig, but you only have the nid? Moreover, it is good practice to use the id and not a hardcored url. Here's what you should use:

 {{ path('entity.node.canonical', {'node': 522}) }}

 


Saved you some valuable time?

Donate and get more free time-saving code on this website in the future.