You can use the following code to set URL alias for a node if your website also uses PathautoWhere $node_url is the desired alias and $node is loaded node object. Tags Node Drupal8 Pathauto Disqus View the discussion thread.