HUGO

Modules running differently in `.yml` vs `.toml`

I was just trying to convert my site’s config.toml to config.yml where I have a simple Hugo Modules import from a local themes folder (there is no go.mod file or anything like that).

This worked:

[module]
  [[module.imports]]
    path = "../../themes/theme-v2"

theme = "theme-v2"

However, this did not:

module:
  imports:
  - path: ../../themes/theme-v2

theme : theme-v2

I’m getting this error:

Error: module "theme-v2" not found; either add it as a Hugo Module or store it in [path/to/theme/folder].: module does not exist

Am I doing something wrong? or is this a bug?

I suggest you use an online TOML to YAML converter, which should show you where you got it wrong.

Also, I suggest you set your themesDir instead of doing this “…/…” dance.

yeah, i know the dance is unfortunate

so, give up on modules? seems like i won’t need them then…


I did do a little investigation, as something didn’t seem quite right. (and, yes, i know the ../.. dance is unfortunate, but, i’m doing it for the sake of experimentation…

this works as expected. (import this theme => use the theme)

[module]
  [[module.imports]]
    path = "../../themes/theme-v2"

theme = "theme-v2"

This works, too… which i guess makes sense, why would you import something if you are not going to use it…

[module]
  [[module.imports]]
    path = "../../themes/theme-v2"

#theme = "theme-v2"

This, however, does not.

module:
  imports:
  - path: ../../themes/henryskup-v2

theme :
- henryskup-v2

This works though…

module:
  imports:
  - path: ../../themes/henryskup-v2

#theme :
#- henryskup-v2