Template suggestion doesn't work with a custom menu link (custom route) In a module I have created a custom link by creating a custom route inside the mymodule.routing.file.yml and the mymodule.links.menu.yml file.
In my theme.theme file I have defined a hook_page_alter to add a template suggestion. With the debug mode and in the html code of the custom page, I see the proposed template suggestions.

&lt;!-- THEME DEBUG --&gt;
&lt;!-- THEME HOOK: 'page' --&gt;
&lt;!-- FILE NAME SUGGESTIONS:
* page--mycustomtemplate.html.twig
x page.html.twig


I have build a new template with this name 'page--mycustomtemplate.html.twig'. After clearing the cache, the new template isn't called, and the default page template is always actived.

Did I forget something?
I'm guessing you put the template in your module folder and not in a theme?

You need to register the template with something like this in your .module file:

/**
 * Implements hook_theme().
 */
function mymodule_theme() {
  $theme['page__mycustomtemplate'] = [
    'template' =&gt; 'page--mycustomtemplate',
  ];

    return $theme;
}