Template suggestions based on path alias I'm trying to work out how I can add my own template suggestions based on the set URL alias. I've found lots of information out there regarding Drupal 7, but very little for 8.

I know I can use hook_theme_suggestions_page_alter(array &amp;$suggestions, array $variables).

Basically, I'm looking to convert this to Drupal 8. 

$alias = drupal_get_path_alias($_GET['q']);
if ($alias != $_GET['q']) {
  $template_filename = 'page';
  // Break it down for each piece of the alias path.
  foreach (explode('/', $alias) as $path_part) {
    // Added the str_replace because path parts with - were not being picked up properly by the theme_hook_suggestions().
    $template_filename = $template_filename . '__' . str_replace("-", "_", $path_part);
    $variables['theme_hook_suggestions'][] = $template_filename;
  }
}
OK, I seem to have got it working.

function THEME_NAME_theme_suggestions_page_alter(array &amp;$suggestions, array $variables) {
  $current_path = \Drupal::service('path.current')-&gt;getPath();
  $result = \Drupal::service('path.alias_manager')-&gt;getAliasByPath($current_path);

  $path_alias = trim($result, '/');
  $path_alias = str_replace('/', '-', $path_alias);

  $suggestions[] = 'page__path_alias__'.$path_alias;
}