How to change theme template for the same block that is loaded twice on the page? We have created two menu blocks: main_menu (region=main nav) and main_menu_footer (region=footer) that are added to all pages. They both are displaying the same main navigation menu except main_menu_footer only displays the first level and main_menu displays all levels. 

I have a custom module, mymodule that I am using to assign a custom twig template, menu--main.html.twig. This twig template is being assigned to both blocks.

How can I setup the twig templates so that the main_menu uses main--menu.html.twig template, but main_menu_footer uses main--menu--footer.html.twig?

Goal:


main_menu block uses main--menu.html.twig template
main_menu_footer block uses main--menu--footer.html.twig template


Current setup

function mymodule_theme($existing, $type, $theme, $path) {
  $items = [];
  $items['main__menu'] = [
    'base hook' =&gt; 'menu',
    'render element' =&gt; 'menu',
  ];

  return $items;
}
This is usually done at the theme level, not the in a module. Unless you want to create your own implementation of a menu.
First of all, enable Twig Debugging then in locate in DOM the templates you want to override.
In your active theme, create a file with the same name as the twig template you want to override. Copy the code from the original template and customize it as you like