I have a view page that requires a dynamic page title. It is a simple substitution of the label field.
If I use {{ label }}
it works fine for the title displayed on the page, but it doesn't substitute the label for the actual page title (in meta)
I was able to fix this by using hook_views_post_render
using the following code
// Set the route title.
$route = \Drupal::routeMatch()->getCurrentRouteMatch()->getRouteObject();
$route->setDefault('_title', $title);
$view->setTitle($title);
However, the title only works if the page is not cached. For the cached pages, the page title is missing. This feels like a bug in drupal, but I am hoping that there is a simple way to get this done.