Skip to main content
6 of 6
edited title
leymannx
  • 18.8k
  • 6
  • 72
  • 126

How can I get the path alias from a node ID or node object?

I have a node object, and I am trying to use it to get a given path in Drupal 8.

There was drupal_lookup_path() in Drupal 7 but I'm not seeing any equivalent or documentation for Drupal 8.

What's the new "Drupal" way to get a path from a node object?

Would it be something simple like $node->get('path')?

This seems like a simple question, but I'm just absolutely not finding any documentation on it.

Notice I do not want the path alias for the current path; I want the path alias for an arbitrary node, given a node object or a node ID.

Jack Ryan
  • 2.3k
  • 4
  • 32
  • 56