"params" from config.toml in component seems not being merged

I struggle with the same kind of problem described in Partial overwrite for outputs option

In the documentation it is written

Also note that a component that is part of a theme can have its own configuration file, e.g. config.toml. > There are currently some restrictions to what a theme component can configure:

params (global and per language)
menu (global and per language)
outputformats and mediatypes

The same rules apply here: The left-most param/menu etc. with the same ID will win.

So I was adding a theme component, and was expecting that I can “overide” some component config.toml option in my main config site.

myComponent config.toml

[params]
   [params.global]
      [params.global.map]
         [params.global.map.osm]
            test1 = "component config test 1"
            test2 = "component config test 2"

I was expecting to overide one entry in my main site config.toml

theme = ["navigator-hugo", "hugo-notice", "myComponent"]

[params]
   [params.global]
      [params.global.map]
         [params.global.map.osm]
            test1 = "main config test 1"
            test2 = "main config test 2"

This is for example from my partials in component and in main site:

{{ site.Params.global.map.osm.test1 }}
{{ site.Params.global.map.osm.test2 }}

I always get the main value (main config test 1 & main config test 2) as result, either in component or in main site.

And if I have no test2 in my main config.toml i get nothing (nil) for site.Params.global.map.osm.test2, even if it is setup in my component.

May be I wrongly understood the documentation ? Any pointer/explanation on what i didn’t understood will be helpfull. Thanks.

It’s merged but it’s shallow merge.

in my case, a theme components will have config.toml like this:

themes/mycomponent-1/config.toml

[params."component-dummy-1"]
  name = "Component  1"

themes/mycomponent-2/config.toml

[params."component-dummy-2"]
  name = "Component 2 "

then in template, i will range the .Site.Params then filter the Params key with component- prefix.

Thanks for the response. I understand and I think I can workaround this.

But reading the doc I was thinking that the params overriding was transparent.

So, thanks for the pointer, I understood how I could manage this.

But my understanding for the doc is confusing because I was expecting the Params should works as template/data/asset/static. And obviously not.

Anyway, thanks for this.

2 Likes