Sub-directories in module's templates directory I have created a module in Drupal 8, which contains a large number of custom templates - these only theme the module's output, and don't override existing template files.

I would like to place these templates in sub-directories of the module's templates directory - for example:

templates/account
templates/orders
etc


If I place a template in a sub-directory, and set the renderer to use a #theme such as 'account/list_block' then the block doesn't render at all, but I get no errors. 

However, critically, if I keep my template in the subdirectory but change #theme back to 'list_block' I get the following error:

Template "modules/contrib/mymodule/templates/list-block.html.twig" is not defined 
(Drupal\Core\Template\Loader\ThemeRegistryLoader: Unable to find template "modules/contrib/mymodule/templates/list-block.html.twig" 
 in the Drupal theme registry.).


Doing the above to deliberately break things would indicate that in the first example Drupal knows the template exists, and where to find it (in the account sub-directory of templates), but is choosing not to render it. Very odd.

Is what I'm looking to do possible?
You just need to specify the path to the template in hook_theme(), eg

function MYMODULE_theme() {
  return [
    'list_block' =&gt; [
      'variables' =&gt; [],
      // Underscores are not converted to dashes automatically in this case.
      'template' =&gt; 'account/list-block',
    ],
  ];
}