I’m building an ecommerce site with multiple languages.
I have set up the data files in their respective language folders eg: Data → en → productlist.json
The productlist.json file assigns a category to each product ie: “id”: “productId”,
“name”: “productName”,
“cat”: “dogs”,
“cat_url”: “dogs”,
In the template I have added: {{ $data := index .Site.Data .Site.Language.Lang }}
{{ range $data.productlist }}
output goes here
{{ end }}
I think this now gives me access to the productlist.json file corresponding to the page language. I now want to output the products by category, to give me a category view page. How would I achieve this?
Thanks for any help. The site files are available here:
The data directory exists outside Hugo’s Multilingual Mode and that is how it should be.
If you want to display different products per language then I suggest that you split that JSON into Markdown Files and place them under the respective Language directories under /content/ with third party tools e.g. jq, Python, Go, Unix shell etc.