Creating Files from Data (like Product pages)

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?

1 Like

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.

Thanks for the quick response.
For now, I will just generate the .md files with an external program.

I assume that changing the data format from CSV to TOML or YAML would not change your answer.

Is there a way for Hugo to read a data file and generate the product files itself?

No, but there is an open issue about it on GitHub, so it might happen … some day.


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.

1 Like

Registering a user here on the forum to post one post about “Jekyll can do this” isn’t helpful.

1 Like

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.


hi @bep could you please write me the URL of the issue related to this task?

Thank you

I would have to look at it, so you might as well do that work yourself.

@bep I’m sorry, before to write you, I have searched, but I did not find anything :frowning:

There is no opened issue related to CSV, and I do not find anything related to this thread in the closed.

Thank you

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

Please follow latest development at “Build pages from data source”

1 Like