Get the route name of the current page
To get the current route name, use:

$route_name = \Drupal::routeMatch()-&gt;getRouteName();


You can add the current page's route name as a variable in your theme's ".theme" file.  Add a _preprocess_page function like this, and clear the drupal cache.

/**
 * Implements hook_preprocess_page().
 *
 */
function mytheme_preprocess_page(&amp;$variables) {
  $variables['route_name'] = \Drupal::routeMatch()-&gt;getRouteName();
}


Then you can access in page.html.twig like this:

{{ route_name }}


Note: \Drupal::routeMatch()-&gt;getRouteName() will sometimes return null. 

If you are inside a class, to do things properly, you'll want to inject the route match service in the constructor and then call it this way:

$this-&gt;currentRouteMatch-&gt;getRouteName()


The constructor (and variable) will be like this:

  /**
   * The current route match.
   *
   * @var \Drupal\Core\Routing\RouteMatchInterface
   */
  protected $currentRouteMatch;

  /**
   * Constructs a new ThemeTestSubscriber.
   *
   * @param \Drupal\Core\Routing\RouteMatchInterface $current_route_match
   */
  public function __construct(RouteMatchInterface $current_route_match) {
    $this-&gt;currentRouteMatch = $current_route_match;
  }


If it's a service class, you'd then pass it into the service in the yaml file in your custom module:

services:
  mymodule.service:
    class: Drupal\mymodule\MyCustomService
    arguments: ['@current_route_match']