Can Hugo create files based on records in a data file?
When I search for “data-driven” in the Hugo docs, the examples seem to describe how to pull data into a “single” file – not how to create a separate file for each record.
My scenario:
I have a CSV file where each record represents a product. I would like to create a separate page for each record.
So far, my only idea is to use a custom external program to parse the CSV and create .md files for each product with zero markdown but data in the top of the file. Then Hugo would process the .md files against a single product template.
Is there a way for Hugo to read a data file and generate the product files itself?
I don’t believe so, outside of a) creating a bunch of templates yourself (which I gather is not what you’re trying to do) or b) creating a smart _default template where maybe something like the front matter includes a value to use when parsing the CSV. If you’re looking for a straight my-csv-to-multiple-content-pages workflow, I don’t think you’re going to get it right out of the box with Hugo.
You can do this with Jekyll with a plugin and it works great. I was also hoping to do this in Hugo as well but looks like I’ll have to wait to switch and just deal with build times in Jekyll.
Although my answer does not provide a solution via Hugo, it provides a solution. I specifically came to the Hugo page to see if I could recreate my current Jekyll site, which has slow build times (a reason to switch) with Hugo. I found this question and answer, which means that no, I cannot switch my current site over. However, if someone needs to create data driven pages, there are options out there, just not Hugo at this point apparently.
My question in other thread (Help on creating html files from data) is obviously duplicate (I just realized that now) so please let me know if something new here happens. BR