Custom module template not detected The page--404 suggestion is visible in the twig debug comments:

function amu_http_status_code_display_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;
}


But it fails to consider the 


  templates/page--404.html.twig


from my module.

I have tried this 

function amu_http_status_code_display_theme($existing, $type, $theme, $path) {

  $arguments= array(
      'template' =&gt; 'page--404',
      'base hook' =&gt; 'node',
  );

  // this is the name of the templates
  return array(
    'page--404' =&gt;  $arguments,
  );
}
thanks to 4k4 comment, i have made it working

/**
 * Setting 40x template suggestions
 */
function amu_http_status_code_display_theme_suggestions_page(array $variables)
{
  $path_args = explode('/', trim(\Drupal::service('path.current')-&gt;getPath(), '/'));
  $suggestions = theme_get_suggestions($path_args, 'page');
  //mapping the route with its suggestion hook
  $http_error_suggestions = [
    '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;
}




/*
 *
 * make drupal knows the templates are located in the module
 *
 * */
function amu_http_status_code_display_theme($existing, $type, $theme, $path) {


  $arguments403= array(
    'template' =&gt; 'page--403',
    'base hook' =&gt; 'page',
  );

  $arguments404= array(
    'template' =&gt; 'page--404',
    'base hook' =&gt; 'page',
  );

  //mapping the hook with its template
  return array(
    'page__403' =&gt;  $arguments403,
    'page__404' =&gt;  $arguments404,

  );
}