Merge config.json and site.json

this might be a newbie question - sorry … I would like to merge the files config.json and /data/site.json. So i did :slight_smile: but in my navbar.html I have the followng line

{{ $URL_EXAM_SHOP := (index site.Data ).site.URL.URL_EXAM_SHOP | default "/" }}

I tried
{{ $URL_EXAM_SHOP := .Site.URL.URL_EXAM_SHOP | default "/" }}

but it did not work. Error Messages

error calling partial: “something/layouts/partials/navigators/navbar.html:1:26”: execute of template failed: template: partials/navigators/navbar.html:1:26: executing “partials/navigators/navbar.html” at <.Site.URL.URL_EXAM_SHOP>: can’t evaluate field URL in type page.Site

Thanks for HELP

PS what does (index site.Data ) do? - list all Files in folder data?

yes. a file like the following in data/test.toml:

fasel = "value"

is accessible at {{ site.Data.test.bla.fasel }}.

1 Like

That error tells you that .Site has no variable .Url defined. Which is true. I think there might have been a site.Url long time ago.

About your question to merge config.json and data/site.json… that is not possible, because the config is not available in it’s entirety. You can define a section params in your config and that one is available via site.Params. Then you can merge the following way:

{{ $fullconfig := | merge site.Params }}

which will merge the site params on top of the data params. have your data/site in a subkey params for that to work.