Path

The path is the part of a Drupal address after the domain, such as /node/7. It names a page or function, not a file, and can carry a readable alias.

Learn DrupalDrupal glossary

In Drupal, a path is the part of a URL that comes after the domain name and identifies one function or piece of content, such as node/7 for a content item. Drupal matches the requested path to a route, and the route produces the page.

How paths work in Drupal 11

The User Guide defines a path as the unique, last part of the URL for a specific function or piece of content. Its examples are node/7 for a content item, taxonomy/term/6 for a term page, user/3 for a profile, user/login for the login form and admin/content/comment for an administration page.

Drupal's routing system does the matching. A route is a path that Drupal uses to return content: when a request arrives, Drupal tries to match the path to a known route, and the route definition produces the response. If nothing matches, Drupal returns a 404. A route path can hold a placeholder in curly braces, as in /example/{name}, and the controller receives the value.

The path you see in a link is not always the system path. When a page has an alias, Drupal looks up the system path behind the alias for an incoming request, and the alias manager turns the system path back into the alias when a link is generated. Both lookups are defined by AliasManagerInterface.

Example

A content item is saved with the system path /node/7. An editor gives it the alias /about. A visitor opens https://example.com/about, and Drupal serves the page that belongs to /node/7. To list every alias and the system path it belongs to, go to Configuration › Search and metadata › URL aliases.

To find the routes a site defines, the routing documentation names two tools: the drush route command and the Devel module's /devel/routes page.

Common mistakes

  • Mixing up path and URL. The path has no scheme and no domain; the URL has both.
  • Dropping the leading slash in code. The User Guide shows node/7, but the alias manager and Url::fromUserInput() expect /node/7. Both reject input without it.
  • Expecting a file behind the path. MDN describes the path of a URL as mostly an abstraction that the web server handles, without physical reality. In Drupal the router decides what the path returns.
  • Quoting the system path as the public address. If the page has an alias, share the alias.

For marketing and content teams

When a developer or a log entry mentions /node/7 or /taxonomy/term/6, that is the internal path of a content item or a taxonomy term. The address visitors should see and share is the alias, if one exists. Ask for the alias in your URL plan, not the system path.

Sources

Questions about Drupal paths

The URL is the full address, including the scheme and domain, such as https://example.com/node/7. The path is only the last part, node/7. The Drupal User Guide uses the same example.

It is the system path: the internal address Drupal gives a content item. An alias such as /about is an optional readable name that the Path module maps to it.

No. Drupal matches the requested path to a route, and the route produces the response. If no route matches, Drupal returns a 404.

In Drupal code, yes. The alias manager methods throw an exception for a path without a leading slash, and Url::fromUserInput() accepts only input that begins with /, ? or #. The User Guide writes paths without it.

Related terms

All Drupal terms from A to Z