Get node internal path from path alias in Twig template I want to get the internal path of a node from its path alias. In Drupal 7 we could use drupal_get_normal_path() directly in the PHP template.

With Drupal 8, Is there a function to get the internal path from an alias inside a Twig template?

In my Twig template I have tried to use the url() function without success...

e.g. {% set path = url('myalias') %} ...
You should not be running Drupal functions inside TWIG templates, the best approach is to use a pre-processor as mentioned in the comments. You can do this by setting a variable inside a hook being called either in your theme file or custom module and setting like this:

$vars['your_custom_variable'] = $unaliasedNodePath


And then inside your twig template you can use the variable set in your pre-processor like this:

{{ your_custom_variable }}


More information can be found here: 

https://www.drupal.org/docs/8/theming/twig/twig-best-practices-preprocess-functions-and-templates