I’ve sketched a minimal example in this repository.
I’ve created some files in Data and I’m accessing them in
layout/index.html. What if I want to access them in a page different from the home page?
IIUC, hugo will render pages only for:
- the home page (index.html, special template file)
- a content type which has its own templates/views
My case is different: I don’t have anything under content/ and I don’t want to render the Data elements on the home page.
What should I do?
I don’t think that’s possible with Hugo at this point. Hugo only creates files based on what it finds in the
content folder. The
data folder is only supplemental to the content. Looking at your repo, why not just move those files into
content/recipes/ and convert your TOML to front matter? You’ll need to rewrite your templates to access the
.Params map for whatever values you define in the front matter, ie.
@moorereason thanks, I supposed that was the reason, but I was not sure.
Perhaps the Data files page in the doc could explain that data files should be better used either in the home page or as an extension to existing content.
for the records, I followed your advice in this commit
And it worked great, right?