How to get the front page title in page.html.twig? I'm trying to use the page title in my theme's page.html.twig. On normal pages, {{ node.label }} does the job, but that doesn't work on the front page. There, node is NULL, presumably because the font page is a view rather than a "real" page.

I have tried to dump all the available variables on page.html.twig using kint, but it seems that none of them contains the page title. Other questions discuss a similar matter, but either only for normal pages or for getting the title from PHP (and not from within a TWIG template).

I'm looking for an approach that works in any template, although page.html.twig is most important for me right now. It should also take a global title override into account. The ideal solution would also work on normal pages (i.e. not the front page).

TL;DR: I'm looking for a template variable/function X so that {{ X }} is the current page title, no matter whether I'm on the front page or on any other page.
You should really try using the blocks for this, but here's how to do what you asked:

function YOUR_THEME_preprocess_page(&amp;$variables) {
  $request = \Drupal::request();
  $route_match = \Drupal::routeMatch();
  $page_title = \Drupal::service('title_resolver')-&gt;getTitle($request, $route_match-&gt;getRouteObject());
  $variables['current_page_title'] = $page_title;
}


This code should go in YOUR_THEME.theme file. You can use it then in page.html.twig this way:

{{ current_page_title }}


See this for more information.