4xx pages template override 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')-&gt;getPath(), '/'));
  $suggestions = theme_get_suggestions($path_args, 'page');
  $http_error_suggestions = [
    'system.401' =&gt; 'page__401',
    'system.403' =&gt; 'page__403',
    'system.404' =&gt; 'page__404',
  ];
  $route_name = \Drupal::routeMatch()-&gt;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?
I have pretty much the same code as you have with the exception that I have a hook_theme_suggestions_page_alter(). With the _alter attached to it.

Try putting the HOOK in a custom module instead of the .theme file.