Display alias instead of node I am trying to create a link in page.html.twig that points to an alias. The code {{ url('node/1') }} shows an unexpected error, whereas {{ 'node/1' }} works fine but goes to url website/node/1.

In D7, one can use &lt;?php echo url('node/1'); ?&gt; and be directed to the page with proper alias.

What code can be used in D8 to display correct alias url?
You can use getAliasByPath function to get the url alias for a path.

Put the below code in THEME_NAME.theme file.

function THEME_NAME_preprocess_page(&amp;$variables) {
  $variables['url_alias'] = \Drupal::service('path.alias_manager')-&gt;getAliasByPath('/node/1');
}


Finally print the url_alias in your page.html.twig file.

{{ url_alias }}