How can I get the page title?
If you check the change records you should find the following: drupal_set_title() and drupal_get_title() were removed.

You'll have to read the change notice for all of the info, but here is a starting point:


  drupal_get_title()
  
  As titles on routes now can be set on various ways (see above),
  drupal_get_title() has been removed. In its place you should call the
  title_resolver service.
  
  Drupal 7

&lt;?php
  $title = drupal_get_title();
?&gt;

  
  Drupal 8

&lt;?php
  $request = \Drupal::request();
  if ($route = $request-&gt;attributes-&gt;get(\Symfony\Cmf\Component\Routing\RouteObjectInterface::ROUTE_OBJECT)) {
    $title = \Drupal::service('title_resolver')-&gt;getTitle($request, $route);
  }
?&gt;