I’m currently exploring Hugo themes and websites, and I’m particularly interested in incorporating filters into my project. Since Hugo primarily generates static pages, I’m looking for guidance on how to implement filters effectively.
I have a list of results that display properties, and these results need to be filterable based on various criteria, such as residential or commercial properties. Furthermore, under the residential category, we have sub-filters like home, apartment and villa etc.
Now, I’m wondering about the best approach for creating such a website in Hugo. Should I generate static pages for every possible filter combination, or would it be better to generate a .json file using Hugo from .md files and then use JavaScript to filter and display the results?
I’m also curious if anyone has already tackled a similar project using Hugo and filters. Your insights and experiences would be greatly appreciated.
the website you mention is using Hugo taxonomy with possibility of only 1 selection this is very easy to achieve in Hugo.
but it becomes very complicated when you combine selections for example select 2 different options and filter. I wonder in such case if it makes sense to generate all combination pages statically or export json data to generate list page results.
I choose to do it with 1 criteria. But you can obviously do it for more the same way. Will also depends on how much critères you have : X * Y * Z.
If a lot then the JS is the way to go
Using Hugo’s method of generating static pages gives website benefit is SEO. while using js I suppose I can fetch data from the .json file to display cards.
But I was wondering if there is an existing demo of such functionality with Hugo. where Hugo export the list results in .json and then filter using js.
This was my first thought but if I have 1000 cards to display wouldn’t that be an issue.
I was thinking to generate a .json file in Hugo and get the results from there. as otherwise 1000 result load will make the page impossible to load.
Do you know of any existing such examples so I can get my head around this in how a Hugo expert might do it. making maximum use of Hugo either output of.json etc.
1000 is only a problem if they have images and you actually load those images. Using an old school lazy load and a load more button fixes this issue. See Hugobricks blog for an example.
I used for calinalefter.com a tutorial from smashing magazine, - search for “How To Build A Progressively Enhanced, Accessible, Filterable And Paginated List”
This theme is using categories, I see the categories are very easy in Hugo to use. But what about non category items in front matter params.
I already made a very big real estate site with almost 20,000 listings and didn’t use any categories and instead made use of front mater items.
Will this technique work the same for for non category items as Hugo generate pages for categories but does not do the same for other frontmatter items.