How to change the title of breadcrumb? I have a route that renders a node. Unfortunately in the breadcrumb the route title is rendered rather than the node title. When I preprocess in hook_preprocess_breadcrumb() inside my module only the preceding links are available inside $variable (not the current route title).

However, if I go to do hook_preprocess_breadcrumb() in my theme, the route title is inside $variables. So I could change it there but I want the functionality to be encapsulated inside my module, not split between module and theme. 

I tried to create my own custom breadcrumb builder but I don't want to build it from scratch as there is some complex functionality built by other developers. I want to get the current breadcrumbs and then just replace the last one (the current page title) with my own. 

I tried hook_system_breadcrumb_alter() as well but again the current page title is not showing up in variables inside my module.

&lt;?php

class DefaultProductListBreadcrumbService implements BreadcrumbBuilderInterface {

  /**
   * Whether this breadcrumb builder should be used to build the breadcrumb.
   *
   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
   *   The current route match.
   *
   * @return bool
   *   TRUE if this builder should be used or FALSE to let other builders
   *   decide.
   */
  public function applies(RouteMatchInterface $route_match) {
    // TODO: Implement applies() method.
    return true;
  }

  /**
   * Builds the breadcrumb.
   *
   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
   *   The current route match.
   *
   * @return \Drupal\Core\Breadcrumb\Breadcrumb
   *   A breadcrumb.
   */
  public function build(RouteMatchInterface $route_match) {
    // TODO: Implement build() method.

    $breadcrumb = new Breadcrumb();
    $breadcrumb-&gt;addLink(Link::createFromRoute('Home', '&lt;front&gt;'));

    return $breadcrumb;
  }

}


For reference, I'm using bootstrap as the base theme with multiple sub themes (it's a multisite). I can't find anywhere that's adding the page title in the theme. I'm also using easy_breadcrumb module but I checked there and the page title is also not shown there.
You could use a title callback, like for example this one from the core node controller:

\Drupal\node\Controller\NodeViewController::title

  public function title(EntityInterface $node) {
    return $this-&gt;entityManager-&gt;getTranslationFromContext($node)-&gt;label();
  }


Your title callback would have other route parameters, so that you can find the correct node, see also https://drupal.stackexchange.com/a/248687/47547.

When using the default option in the Bootstrap theme to display the page title you might need to add cache metadata to the breadcrumb, see Breadcrumbs are cached, which depends on how you determine the node to display.