hook_theme() in a custom file of my module I'm facing an issue for a few hours now. I created a new module that must render an admin page with some settings and another one with analytics data. The second one must use a custom template file that I created for the occasion.

I added a hook_theme() in my .module file and everything worked fine for a while.

When refactoring my code I wanted to move the hook_theme() in a subfile.inc of my module. Even though I cleared the caches, I always get the issue Theme hook "my_custom_template" not found..

After moving back the hook in the .module file everything work again.

Are they some hooks that must be in the .module file only. As the hook_install() and hook_uninstall() must be in the .install file?
Just to clarify, you mean the actual hook_theme() implementation, correct? Not a theme hook you are defining in hook_theme(). If so, by default, all hooks must be in the .module file. Hooks are meant to be callable at any time, and only .module files are loaded by default on every page load. However you can tell Drupal that a hook is in a different file by implementing hook_hook_info():

function hook_hook_info()
{
   $hooks['theme'] = ['group' =&gt; 'theme'];

   return $hooks;
}


With this code, Drupal will look for the hook (the array key 'theme') in the file MODULENAME.GROUPNAME.inc. In this case your GROUPNAME is defined as 'theme' in hook_hook_info(), so Drupal will load MODULENAME.theme.inc, whenever hook_theme() is invoked.

Now, if you meant that you want to put a theme hook that you define inside hook_theme() in another file, then you need to declare the file for that theme hook:

function hook_theme()
{
  return array
  (
    'some_theme_key' =&gt; array
    (
      'variables' =&gt; array(),
      'file' =&gt; 'path/to/file.inc', // relative to module root
    ),
  );
}


In this case, when the system tries to load the theme some_theme_key, it will load the file [MODULEFOLDER]/path/to/file.inc.