Theme as Module cannot be found

Hello,

I followed multiple tutorials in order to setup a theme as a module.

Minimum example:

$ hugo new site mysite
$ hugo mod init mysite
$ mkdir -p config/_default
# config/_default/module.toml
[hugoVersion]
extended = true
min = "0.124.1"

[[imports]]
path = "github.com/yihui/hugo-xmin"
disable = false
# hugo.toml
baseURL = 'https://example.org/'
languageCode = 'en-us'
title = 'My New Hugo Site'

theme = ['hugo-xmin']
$ hugo mod get
Error: failed to load modules: module "hugo-xmin" not found in "/mnt/d/prog/my_blog/mysite/themes/hugo-xmin"; either add it as a Hugo Module or store it in "/mnt/d/prog/my_blog/mysite/themes".: module does not exist

I could not resolve this issue unfortunately and could also not find a single tutorial that explains this. Thank you in advance.

What about: Use Hugo Modules | Hugo

And remove theme from your hugo.toml

1 Like

@irkode is correct.

  • When you add a theme as a Hugo Module, specify an import path:

    [[module.imports]]
    path = 'github.com/owner/mytheme'
    
  • When you add a theme that resides in the themes directory, set the theme value:

    theme = 'mytheme' # to add a single theme
    theme = ['mytheme'] # to add one more themes with left-to-right precedence
    

Do one or the other… not both.

1 Like

Oh wow, that was actually very simple to fix! Seems like I got lost in between the different tutorials.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.