I encountered this when I had to build a hero paragraph. I needed the page title inside my paragraph. 

This is how I did it. To my mytheme.theme file I added

function mytheme_preprocess_paragraph(&$variables) {
    $paragraph = $variables['paragraph'];
    // if type hero
    if ($paragraph->bundle() == 'hero') {
      $request = \Drupal::request();
      $route_match = \Drupal::routeMatch();
      $variables['page_title'] = \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject());
      $variables['#cache']['contexts'][] = 'url';
    }
}

Now I can just use

{{ page_title  }}

 

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!