Each of these Markdown files is generated automatically and contains precomputed fields (such as price or price ranges). Hugo simply loads these files and renders pages based on the existing data without performing any additional calculations.
so your range definition can be calculated before (in the scripts) something like priceclass: one or do you need the flexibility to define the ranges at generation (hugo)time? or are the price ranges the base for your selection.
one more. you mentioned 4 ranges which result in 2500 items per page. quite a lot. any plan how to handle that?
Each folder represents one static price-range page.
Step 2: Hugo filters cars for that range
In layouts/price/list.html:
Hugo checks the current price range
Filters cars at build time
Outputs only cars that belong to that range
No JavaScript filtering is needed on these pages.
3. Why not generate ranges in scripts?
If we generated priceClass in JS:
All cars still need to be loaded first
Filtering happens after page load
Performance and payload size remain poor
Using Hugo build-time filtering means:
Smaller HTML
Faster load
Cleaner logic
Better SEO
So flexibility is intentionally sacrificed for performance and clarity.
4. About “2500 items per page” — what’s the plan?
Current state (honest answer)
Right now:
We do not have pagination
A price range page can have many cars
Why this is still acceptable (for now)
Earlier:
One page loaded all cars across all ranges
JS just hid and showed them
Now:
Only one price range loads at a time
Users never download unrelated data
So even 2500 items:
Is already a big improvement
Is limited to a single, intentional page
5. Future handling (not implemented yet)
Later we can add:
Pagination
Lazy loading
Infinite scroll
But the foundation is correct:
Price ranges defined at build time
Data split into static pages
No client-side heavy filtering
Short final answer
Price ranges are not calculated dynamically in scripts. They are defined at Hugo build time and are the base for selection. Each price range has its own static page, and Hugo filters cars during generation. This avoids loading all cars in the browser and fixes the performance issues we had earlier. Large result sets are currently accepted per page, but only within a single price range, and pagination can be added later if needed.
The content/price/ directory is structured as 0-5-lakh/_index.md, 5-10-lakh/_index.md, 10-20-lakh/_index.md, and 20-lakh-plus/_index.md, with each folder representing a specific price range. Hugo treats each _index.md as a section page and generates a separate static page for every price range at build time using a shared template located at layouts/price/list.html. Car data is filtered by price range entirely during the build process based on the front matter defined in each _index.md, eliminating the need for any client-side JavaScript filtering. This results in clean, maintainable code, faster page loads, and improved SEO through fully pre-rendered static pages for each price range.