When I debug it with printf, it tells me that the value is nil. I’m pretty sure this is a context issue, but I can’t understand what I did wrong. I put a dot . after each of my partials, as described in the doc to avoid this issue.
If you have any idea of what might be the problem it will be very nice !
In fact it was just an exemple, in reality I want to access the .Site.Data variable, exactly like in my products.html partial :
<!-- I got en/fr folders inside my data folder -->
<!-- so this line is necessary in order to get the correct data according to the current language -->
{{ $data := (index $.Site.Data .Lang)}}
<!-- then access index.yml (which reside inside my data folder) variables -->
{{ $data.index.someVariable }}
index refers to my index.yml file, which resides into my data folder.
Sorry for my explanation, my original question was : why can I access to $.Site.Data inside my products.html partial, but not inside my feature.html partial (which resides into the products.html partial) ?
When I try to access $.Site.Data into my feature.html partial, my hugo build failed with this error :
It’s really difficult to troubleshoot an instance without running it locally. I suggest you break out the templates in question into a sample repo, and share that. Many times, in doing so, folks actually figure out their issue, because the reduced complexity illuminates the issue. For your consideration.
You need to pass multiple values to your feature partial, but partials only take a single context parameter. To cram multiple values into a single value, you can build a dictionary on the fly.
That was the answer I was looking for! I didn’t know the existence of dict, but now everything makes perfect sense. I managed to succeed what I wanted to do, I only needed to access the Site variables from the nested partial.