Hi! Should _merge = deep work with theme modules, for menus?
I have a bunch of sites which all use a theme module. There is a config/_default dir, for the sites and the theme, and inside each, a hugo.toml and menus.toml file. I know Hugo “sees” the theme’s menus because if I take away the site’s, it renders. But when they both co-exist, it won’t show the superset of both menu groups. They have the same name (footer).
I put _merge = "deep" in both menus.toml files, and also tried it
[module]
_merge = “deep”
[[module.imports]]
path = “path”
I also tried where the theme is not a module, but contained within the site.
Many thanks for any thoughts, if I should keep working on this or if it’s not a possible.
Are both under the same identifier (e.g., “main”)?
The menus have the same name, but the identifiers of the items vary. They are all footer.
so _default/menus.toml in the site is
_merge = "deep"
[[footer]]
identifier = "home"
name = "Home"
url = ""
weight = -110
but in the theme
_merge = "deep"
[[footer]]
identifier = "test"
name = "test"
url = "https://external.link"
weight = -110
(should they both have _merge = “deep” ?)
In your project configuration, maps can be merged from a theme/module configuration, but slices cannot.
We should explicitly state that here:
https://gohugo.io/configuration/introduction/#merge-configuration-settings
See https://github.com/gohugoio/hugoDocs/issues/3494.
Note that this merge behavior is not specific to menus.
Reference: https://github.com/gohugoio/hugo/issues/12584#issuecomment-2160471195
Thank you! So we can make a new slice then… It looks like if I call the project menu footer and the shared theme menu footer_shared then I can see them both. (after adding a new range loop to the partial.)
Much appreciated, have a wonderful day.
I’ve udpate the documentation. See the admonition at the bottom of this section:
https://gohugo.io/configuration/introduction/#merge-configuration-settings