0

Drupal seems to be adding some default breadcrumbs that come from the URL. How can I disable this feature? I don't see it in configuration but maybe I'm looking in the wrong place.

3
  • 1
    Given that the question is not making clear what exactly those default breadcrumbs are, and you want to be selective on which part to remove from the breadcrumbs, this question is too broad. The only possible answer is change the service used from Drupal to build breadcrumbs, but this is a too minimal answer.
    – apaderno
    May 13, 2019 at 7:44
  • The Easy Breadcrumb module adds quite a bunch of configuration to Drupal's core breadcrumbs. Include/exclude certain path or segments etc..
    – leymannx
    Sep 17, 2019 at 10:36
  • And then there's also hook_system_breadcrumb_alter you can use to override things.
    – leymannx
    Sep 17, 2019 at 10:38

2 Answers 2

4

The default breadcrumb builder is defined in the system services file and has the priority 0:

system.services.yml

  system.breadcrumb.default:
    class: Drupal\system\PathBasedBreadcrumbBuilder
    arguments: ['@router.request_context', '@access_manager', '@router', '@path_processor_manager', '@config.factory',  '@title_resolver', '@current_user', '@path.current']
    tags:
      - { name: breadcrumb_builder, priority: 0 }

If you want to turn off the default breadcrumb builder you define one with a higher priority. This is an example for taxonomy terms:

taxonomy.services.yml

services:
  taxonomy_term.breadcrumb:
    class: Drupal\taxonomy\TermBreadcrumbBuilder
    arguments: ['@entity.manager']
    tags:
      - { name: breadcrumb_builder, priority: 1002 }

With the method applies() you choose for which routes the breadcrumb builder should be used:

TermBreadcrumbBuilder::applies()

  public function applies(RouteMatchInterface $route_match) {
    return $route_match->getRouteName() == 'entity.taxonomy_term.canonical'
      && $route_match->getParameter('taxonomy_term') instanceof TermInterface;
  }

The breadcrumb manager checks all applies() methods, starting with the highest priority, until it reaches the default breadcrumb builder, which applies for all routes:

PathBasedBreadcrumbBuilder::applies()

  public function applies(RouteMatchInterface $route_match) {
    return TRUE;
  }
-1

In D8, breadcrumbs are now blocks. They can be disabled in Block Layout.

2
  • Hi but I dont want to delete all of the breadcrumbs, just the ones that drupal core adds
    – Diana
    May 19, 2017 at 21:29
  • That wasn't the question.
    – Christian
    Nov 11, 2020 at 3:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.