I am trying to implement the solution given in this question.
I want to have custom templates for 4xx pages.
I am using Drupal 8.3.1
I have tried the code as given in the above link to create the page suggestions in my theme's .theme file:
/** * Implements hook_theme_suggestions_page() to set 40x template suggestions */ function MY_THEME_NAME_theme_suggestions_page(array $variables) { $path_args = explode('/', trim(\Drupal::service('path.current')->getPath(), '/')); $suggestions = theme_get_suggestions($path_args, 'page'); $http_error_suggestions = [ 'system.401' => 'page__401', 'system.403' => 'page__403', 'system.404' => 'page__404', ]; $route_name = \Drupal::routeMatch()->getRouteName(); if (isset($http_error_suggestions[$route_name])) { $suggestions[] = $http_error_suggestions[$route_name]; } return $suggestions; } It does not appear to work.
page--404.html.twig or page--system--404.html.twig are not being used.
404 and 403 pages are not set inside the admin of the page.
What else am I suppose to do to get this working?