Menu Breadcrumb
Generates breadcrumbs based on menu position and titles, with support for taxonomy-based attachment for pages not directly on menus.
menu_breadcrumb
Install
composer require 'drupal/menu_breadcrumb:^2.0'
composer require 'drupal/menu_breadcrumb:8.x-1.16'
Overview
Menu Breadcrumb provides a powerful alternative to Drupal's default path-based breadcrumb system by generating breadcrumbs based on menu structure. The module determines the breadcrumb trail by examining which menu the current page belongs to, displaying the hierarchical path through that menu as the breadcrumb.
One of the module's most powerful features is "Taxonomy Attachment," which allows pages that are not directly on any menu to inherit breadcrumbs from a taxonomy term they belong to. For example, blog entries that are tagged with a category will inherit the breadcrumb trail of that category's menu position, even though the blog entries themselves are not menu items.
The module supports multilingual sites with per-menu language handling, ensuring that menus are only breadcrumbed when their language matches the current content language. Multiple menus can be configured with different priorities, and the module will use the first matching menu to generate breadcrumbs.
If no menu match or taxonomy attachment is found, the module gracefully steps aside, allowing other breadcrumb builders (such as Drupal's default path-based builder) to handle the breadcrumb generation.
Features
- Generate breadcrumbs based on menu hierarchy instead of URL path structure
- Taxonomy Attachment feature that provides menu-based breadcrumbs to pages not directly on menus by inheriting breadcrumbs from their taxonomy terms
- Per-menu language handling for multilingual sites with separate menus per language
- Configurable menu priority through drag-and-drop reordering to control which menu takes precedence
- Option to append the current page title to the breadcrumb trail as a link or plain text
- Option to append taxonomy-attached member pages to the breadcrumb trail
- Configurable Home link handling: add, remove, or use site name as Home title
- Option to use menu parent title instead of "Home" for the front page breadcrumb
- Exclude menu items with empty URLs from the breadcrumb trail
- Exclude disabled menu items from the breadcrumb trail
- Stop breadcrumb trail at first matching URL in the menu
- Option to disable menu-based breadcrumbs for admin pages
- Derived MenuActiveTrail option for improved performance on multilingual sites with large menus
Use Cases
Blog with Category-Based Breadcrumbs
A blog site where articles are tagged with categories but not individually placed on menus. By enabling Taxonomy Attachment on the main menu and adding category taxonomy terms to the menu, all blog articles will automatically inherit breadcrumbs based on their category. For example, an article tagged with 'Technology' will display: Home > Blog > Technology > [Article Title].
Multilingual Site with Separate Menus
A multilingual website with a separate main menu for each language (e.g., main-en, main-fr, main-de). Enable Language Handling for each menu to ensure that only the menu matching the current content language is used for breadcrumbs. This prevents breadcrumbs from appearing in the wrong language.
E-commerce Product Breadcrumbs
An e-commerce site where products are organized by taxonomy categories but not all products are menu items. Add product categories to the menu and enable Taxonomy Attachment. Products will inherit breadcrumbs from their category: Home > Shop > Electronics > Smartphones > [Product Name].
Documentation Site with Hierarchical Navigation
A documentation site with a deep menu hierarchy. Configure the module to append the current page to breadcrumbs and show it as plain text (not a link) so users can see their location. Enable 'Stop on first match' if pages appear in multiple sections to use the first menu occurrence.
Corporate Site with Clean Breadcrumbs
A corporate site that wants clean breadcrumbs without the Home link cluttering the display. Enable 'Remove Home link' to have breadcrumbs start directly with the first-level menu item. Or set 'Home title' to use the site name for better branding in breadcrumbs.
Tips
- The module has a high priority (1010) so it runs before core's taxonomy breadcrumb builder. If you want another module to handle breadcrumbs first, you may need to adjust service priorities.
- For performance on large multilingual sites, enable 'Derive MenuActiveTrail from RouteMatch' to avoid using the global MenuActiveTrail service.
- When a page exists on multiple menus, the order of menus in the settings determines which one is used. Drag more important menus to the top of the list.
- Taxonomy attachment searches taxonomy terms in the order their entity reference fields appear in the content type's field listing. Reorder fields if the wrong taxonomy is being matched.
- The module adds url.path cache context to all breadcrumbs to ensure proper caching behavior across different pages.
- When using taxonomy attachment, the taxonomy term's breadcrumb is always shown as a link, regardless of the 'current page as link' setting, because the current page is not actually on the menu.
- Clear caches after changing menu structure to ensure breadcrumbs reflect the updated hierarchy.
Technical Details
Admin Pages 1
/admin/config/user-interface/menu-breadcrumb
Configure how menu-based breadcrumbs are generated. Select which menus to use for breadcrumb generation, configure display options for the current page and Home link, and set up taxonomy attachment for pages not directly on menus.
Hooks 2
hook_help
Provides help text for the module on the admin help page and the settings form page.
hook_system_breadcrumb_alter
Adds url.path cache context to all breadcrumbs to prevent pages not handled by Menu Breadcrumb from having their cached breadcrumb incorrectly replace other pages.
Troubleshooting 7
Clear the Drupal cache. Different module versions use different service arguments, and the cache needs to be rebuilt to recognize the new service definition. Visit /admin/config/development/performance and click 'Clear all caches' or run 'drush cr'.
Ensure that: 1) The menu with the taxonomy term has 'Taxonomy Attachment' enabled in the settings, 2) The content type has an entity reference field targeting taxonomy terms, 3) The taxonomy term is actually placed on an enabled menu, 4) The field value is saved on the node.
Check the menu priority order in the settings. Drag the preferred menu higher (lower weight) in the list. The first enabled menu with a matching path or taxonomy attachment will be used.
Enable 'Language Handling' for each language-specific menu. This ensures menus are only used when their language matches the current content language.
Enable 'Append current page to breadcrumb' in the settings. If it should appear as a link, also enable 'Show current page as link'.
Enable 'Exclude menu items with empty URLs' to filter out menu items that use <none> or have empty link fields.
Enable 'Exclude disabled menu items' to filter out menu items that are not enabled in the menu.