Skip to main content
$route object was unclear. Added $route and $title variables for more clarity.
Source Link

Setting only the _title property to set the page title tag was not enough in my case.

Overriding the title_callback property did the trick :-)

$title = 'something';
$route = \Drupal::routeMatch()->getCurrentRouteMatch()->getRouteObject();
$route->setDefault('_title_callback', function() use ($title) {
  return $title;
});

Setting only the _title property to set the page title tag was not enough in my case.

Overriding the title_callback property did the trick :-)

$route->setDefault('_title_callback', function() use ($title) {
  return $title;
});

Setting only the _title property to set the page title tag was not enough in my case.

Overriding the title_callback property did the trick :-)

$title = 'something';
$route = \Drupal::routeMatch()->getCurrentRouteMatch()->getRouteObject();
$route->setDefault('_title_callback', function() use ($title) {
  return $title;
});
added 26 characters in body
Source Link

Setting only the _title property to set the page title tag was not enough in my case.

Overriding the title_callback property did the trick :-)

$route->setDefault('_title_callback', function() use ($title) {
  return $title;
});

Setting only the _title property was not enough in my case.

Overriding the title_callback property did the trick :-)

$route->setDefault('_title_callback', function() use ($title) {
  return $title;
});

Setting only the _title property to set the page title tag was not enough in my case.

Overriding the title_callback property did the trick :-)

$route->setDefault('_title_callback', function() use ($title) {
  return $title;
});
Source Link

Setting only the _title property was not enough in my case.

Overriding the title_callback property did the trick :-)

$route->setDefault('_title_callback', function() use ($title) {
  return $title;
});