Enable Views contextual filter page <title> overriding in Drupal 8

Views in Drupal doesn’t seem to support a contextual filter value overriding the <title> of a view being displayed as a page. The heading on the page changes, but the title in the <head> of the document isn’t altered.

Here’s one way how to have a custom module take the view title (with the contextual filter override correctly inserted) and apply it to the route (page) title:

(Note that that is a very targeted hook_views_post_render function in a specific custom module and so it bails out early if the ID and display don’t match what we’re looking for. In a more general module you’d want to remove the early return call and instead wrap lines 13–15 in another if statement)

Show your support

Clapping shows how much you appreciated Phil Wolstenholme’s story.