I need some feedback on organizing content for a web shop in Hugo and whether to use a data file or just create leaf bundle content pages for the items since I can access their images as page resources. How are others doing this? I will have about 50-60 items for now, which may grow overtime to several hundreds.
Good that you think about that before you start 50 to 60 items now which may grow to several hundreds screams for a data file. Just think of having a big sale with 20% discount on all items… you don’t want to go through hundreds of files to fix that. Or maintaining stock information. Also adding new products can be made very easy using something like Google Spreadsheets or Notion where you have nicer editing components and then you just export something as json or csv.
Long story short: data file.
Thanks. The bigger issue was how to include image links since I was avoiding hard coding their links in the data file.
Your products typically have an ID (SKU in many systems). Photo names would start with SKU12345 and end with the image name. SKU12345-front-view.jpg. And then you use resources.Match with “SKU12345*” to retrieve all photos for a product.
taking it from another point of view
My Long Story short: it depends
to my experience there is no such think as THIS or THAT.
TR;TR
- how is your data created? really manual - not much fun if the one data file grows
- how about having only some items for discount - maybe you need a tag system there.
- how feature rich is your data(item) to json engine? what can you generate (if you have one)
- what are the pages you want to display? how is your search …
- how much dynamic stuff using js
- …
as @davidsneighbour mentioned usually have an ID, so might be some common properties in a central data. and item specific properties at the item.
- you could store the one teaser image in the assets folder to get it by ID and store local images you only need for a page at the pages level.
- you could create separate datafiles for each item
- you could …
that all said - its about your data modelling, your toolchain and your Requirements