Split config: module.toml doesn't work, but module.yaml does

Ok so initially I was going to make a case stating that modules don’t seem to work with split config.
Then for lols I tried making a module.yaml and was surprised to see it worked.

I’ve made a simple example repo of my issue:

I have the two files:

config/_default/module.toml

[[module.mounts]]
  disableWatch = false
  lang = ''
  source = 'toml/content'
  target = 'content'

config/_default/module.yaml

mounts:
- disableWatch: false
  excludeFiles: null
  includeFiles: null
  lang: ""
  source: yaml/static
  target: static

And to my surprise only the module.yaml seems to be able to set any config.
I use this language, cause module.toml is clearly parsed, cause if we add f.x. another target = 'content' to it, the parser complains when Unmarshaling. So it is clearly parsed, just not honored.

Output from hugo config mounts:

❯ hugo config mounts
{
   "path": "project",
   "version": "",
   "time": "0001-01-01T00:00:00Z",
   "owner": "",
   "dir": "/Users/repsej/dev/personal/hugo/hugo-split-config-module.toml",
   "mounts": [
      {
         "source": "yaml/static",
         "target": "static"
      },
      {
         "source": "content",
         "target": "content"
      },
      {
         "source": "data",
         "target": "data"
      },
      {
         "source": "layouts",
         "target": "layouts"
      },
      {
         "source": "i18n",
         "target": "i18n"
      },
      {
         "source": "archetypes",
         "target": "archetypes"
      },
      {
         "source": "assets",
         "target": "assets"
      }
   ]
}

Glad I noticed .yaml was honored, then I am not blocked. But still baffling and wanted to report it.

Thanks for making Hugo

1 Like

from Configuration Introduction

Omit the root key
When splitting the configuration by root key, omit the root key in the component file.

try this in config/_default/module.html

[[mounts]]
  disableWatch = false
  lang         = ''
  source       = 'toml/content'
  target       = 'content'
[[mounts]]
  disableWatch = false
  lang         = ''
  source       = 'yaml/static'
  target       = 'static'
> hugo config mounts
"mounts": [
  {
    "source": "toml\\content",
    "target": "content"
  },
  {
    "source": "yaml\\static",
    "target": "static"
  }...

Aaah yes!
It was me being bad with toml, I only dropped the [module] at the top.

Thanks irkode.

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