Skip to main content
4 of 6
added 2 characters in body
Jack Ryan
  • 2.3k
  • 4
  • 32
  • 56

Get path alias from NID (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.

EDIT: I do not want the current path. I want a path based on an arbitrary node object or NID.

Jack Ryan
  • 2.3k
  • 4
  • 32
  • 56