How do I get the page title for use in a theme? I'm using Drupal 8.
I've tried searching the Drupal web site and I looked at a few questions on here and I can't seem to figure it out.
Here is what I'm trying in my template_preprocess_page:
$request = \Drupal::request();
$route_match = \Drupal::routeMatch();
$variables['page_title'] = \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject());
However, {{ page_title }} does not work. It seems as if the value is null.
{{ page['#title'] }}
. So no need for the code mentioned in the duplicate.