Breadcrumbs

Breadcrumbs are the Home › Section links above a page's content; in Drupal, builder services compute them and a block prints them.

Learn DrupalDrupal glossary

Breadcrumbs are a trail of links, such as Home, Products, Shoes, that shows where the current page sits in a site. Drupal core's general builder works from the URL path, not from a menu: each parent segment of the address that leads to a page the visitor may view becomes a link. A Breadcrumbs block prints the result in a theme region.

How breadcrumbs work in Drupal 11

The breadcrumb service is a BreadcrumbManager. It collects every builder tagged breadcrumb_builder and asks them in priority order. The first builder whose applies() method returns TRUE builds the trail. The general one is PathBasedBreadcrumbBuilder in the System module, which has the lowest priority and applies to every request. The Taxonomy module adds a builder for term pages that follows the parent terms, and the Comment and Help modules add builders for their own pages. After the builder has run, any module can change the result with hook_system_breadcrumb_alter().

The path-based builder starts from the request path before aliases are resolved, so a hierarchy of path aliases defines the trail. It removes the last segment, which is the current page, and walks upward. For each parent path it looks for a matching route, checks access, asks for the page title and adds a link only when all three work. At the front it adds a Home link. On the front page it returns an empty trail, and it skips /user, which only redirects.

The Breadcrumbs block (plugin system_breadcrumb_block) prints the trail. Olivero places it in its Breadcrumb region.

Example

A visitor opens /products/shoes/sneakers. Drupal checks /products/shoes and then /products. If both are pages the visitor may view, the trail reads Home, Products, Shoes. Each link text is the page title, not the words in the URL, and the sneakers page itself is left out. If nothing answers at /products, that segment is skipped and the trail reads Home, Shoes.

Common mistakes

  • Expecting the menu to drive the trail. Core reads the URL. A menu-based trail needs a contributed module such as Menu Breadcrumb.
  • Using flat aliases. A page at /sneakers has no parent path, so its trail is Home alone.
  • Looking for the current page. Core leaves it out. Add it with a module such as Easy Breadcrumb or in the theme.
  • Forgetting the block. No Breadcrumbs block in a printed region means no trail, whatever the URLs look like.

For marketing and content teams

The trail is a by-product of your URL structure. A parent link appears only when a page exists at the parent path and the visitor may view it, so a restricted section can show shorter trails to anonymous visitors. Because link text comes from page titles, renaming a parent page changes the label in every trail below it. Agree on the alias structure with your developer before you publish a section.

With DXPR

DXPR Theme has a Show Breadcrumbs option in the Page Title section of its theme settings, with choices for alignment and separator. Its breadcrumb preprocess function removes the Home link and, when parent links remain, appends the current page title as the last item. See DXPR Theme.

Sources

Questions about Breadcrumbs

Core builds the trail from the parent segments of the URL. A page at a one-segment address such as /sneakers has no parent, so only Home remains. A parent segment is also dropped when no page answers at that path or the visitor may not view it. Move the page under a real parent alias to get more links.

The core builder removes the last segment of the path before it starts, so the trail lists only ancestors. The contributed Easy Breadcrumb module adds the current page title, according to its project page, or a theme can append it in a preprocess function.

Not in core. The contributed Menu Breadcrumb module builds the trail from the titles of the parent menu items, according to its project page. It lists Drupal 9, 10 and 11 as supported.

Open Structure › Block layout, pick the theme and place or remove the Breadcrumbs block. The theme must print the region you choose. On the front page the core builder returns an empty trail.

Related terms

All Drupal terms from A to Z