Using multiple config files

From the docs:

In addition to using a single site config file, one can use the configDir directory (default to config/ ) to maintain easier organization and environment specific settings.

  • Each file represents a configuration root object, such as Params , Menus , Languages etc…

I have some troubles finding the right interpretation for “represents”.

Starting with a functional config config.toml that has (a.o.)

languageCode = ...
baseURL = ...
[params]
...
[menu]
[[menu.main]]
    identifier = "home"
    post = "left"
    name = "Over ons"
    title = "Over ons"
    url  = "home/index.html"
    weight = 1
...

Now I’ve put the complete [menu] section into a separate file config/_default/menu.toml. I get a very interesting (and not quite helpful) error message:

unable to cast map[string]interface {}{"main":[]map[string]interface {}{map[string]interface {}{"identifier":"home", "name":"Over ons", "post":"left", "title":"Over ons", "url":"home/index.html", "weight":1}....
1 Like
[[main]]
  identifier = "home"
  post = "left"
  name = "Over ons"
  title = "Over ons"
  url  = "home/index.html"
  weight = 1

This was not intuitive. The clue was here:
https://discourse.gohugo.io/t/config-dir-support-added-please-take-it-for-a-spin/15769/5

4 Likes

Thanks!

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