Jul 29, 2019 in Drupal 8, Snippets

Twig is the theme engine in drupal 8 sites. This snippet how to link to nodes correctly, without using preprocess functions to do it.

<a class="button" href="{{ path('entity.node.canonical', {'node': 23}) }}">{{ 'Newsletter'|t }}</a>
// This links correctly to /node/23 and will end up showing the alias f.e. /en/newsletter