I am building a product marketplace using Hugo. Users can filter products by:
- Location (always selected, comes from session)
- Category and Subcategory (subcategory only works if category is selected)
- Price Range (4 fixed options)
- Other filters like: product age, usage, condition, availability, and color
For these dynamic filters (age, usage, condition, etc.), I generate a JSON file during build time and store it in the public folder. These filters are applied on the frontend using URL query parameters.
What I’m Doing Right Now:
I am pre-generating pages for many filter combinations during build time. For example:
/location/mumbai//location/mumbai/electronics//location/mumbai/electronics/phones//location/mumbai/electronics/upto-5k/
Each page has:
- an
_index.mdfile - a JSON file with filter data
Dynamic filters (like color, condition, etc.) are handled using URL query parameters and json.
My Questions:
-
Is it a good approach to generate so many pre-built
_index.mdfiles for all filter combinations? -
I checked that JSON is not very heavy for the system. So instead of generating many markdown files, is it better to use only JSON and handle everything on the frontend?
-
If I use only JSON + query parameters, how should I handle SEO for filtered pages?
Do I need canonical URLs or meta tags? -
Is there any better way to make this system faster, more reliable, and scalable for handling large data in the future?