I am working on a personal portfolio website which includes some project pages for films I worked on. They should all have a “credits” section. I want this section across all “movie” pages to have the same style and follow the same structure.
The way I was thinking of approaching this is to have YAML files in the data folder, each with the same file name as the corresponding .md file. Then I would use some function to automatically have the template look for the data source with the same name.
So for example I have movie1.md which would somehow look automatically for a data file under DATA/CREDITS called movie1.yaml
So my questions are:
How would I make this connection inside the template?
Is this even the right approach? I imagine this isn’t an uncommon thing so I assume there’s a ‘right way’ of doing this.
Lastly how would you go about creating a toggle, so that if there is no associated file - it simply isn’t creating that section on the page?
Just for context: I am a non-professional web developer, coming from film/design/animation background. I have some background in HTML and recently learned some CSS. I’m doing this as a personal challenge (And also to get rid of my Wix account), so I have better understanding than a total non-developer, but definitely a lot of holes in my knowledge compared to someone who does it for a living.
So you’re saying if the data is only relevant to a specific page, keep it as a data file in that page bundle instead of referencing a data file in the data folder?
I tried this a few months ago and Hugo server would often fail to reflect the changes in the watcher. Moving the files to the assets folder and the issue has never recurred since.