How do I use a theme as a Hugo module?

I have a theme which I want to include in my website as a Hugo module, and not as a git submodule. How do I achieve this?

This is what I’ve tried:

# config.yaml
theme: hugo-yami

module:
  imports:
    - path: github.com/UtkarshVerma/hugo-yami

This gives me the error:

Error: module "hugo-yami" not found; either add it as a Hugo Module or store it in "/home/subaru/GitHub/utkarshverma.github.io/themes".: module does not exist

hugo-yami is a theme I’ve made for myself.

A random guess led me to theme: github.com/UtkarshVerma/hugo-yami which works.

I can’t find it now, but in the beginning of Hugo’s modules age I remember bep saying that you EITHER use modules OR themes. I would leave the theme config out of your config files and it should use the theme from the module without any further configuration.

Bear in mind that this means ALL layout files from modules are loaded as theme and merged (last file loaded wins < assumption, not tested).