I couldn’t describe better as a title so… based on this topic, considering the Data Files are hierarchically structured instead - like /data/folder1/folder2/folder3/file.json
- is it possible to get this specific file if the path is unknown, in the meaning of coming from a variable?
For example, considering the path is stored in a FrontMatter Parameter, like:
---
data: folder1/folder2/folder3/file
---
In the template I should do something like:
{{ (index (index (index (index .Site.Data "folder1" ) "folder2" ) "folder3" ) "file" }}
Or the reverse, it’s just a pseudo-code I wrote right now, I didn’t really test
But not only this is not practical, but this defeats the purpose of a dynamically specified path/node and, therefore, I can’t use one single template for multiple sections with minimal variations between them.
Imagining Hugo could be nifty in this matter, I also tried, without success, of course, this:
{{ (index .Site.Data "folder1.folder2.folder3.file" ) }}
The last attempt I could try, but I don’t really have a clue about how to do it (so far I’ve only seen this in the Hugo Debug Partial in a Gist), would be using a recursive partial, thus index-ing N times, as long as dots or slashes would exist in the string.
Anything else I might now know?