Question: How to create a search results page in Hugo using FlexSearch (best practice)?
I’m using Hugo with FlexSearch for client-side search.
Current situation
-
Hugo generates an
index.jsonat build time -
FlexSearch is used in JavaScript
-
Right now search works as inline autocomplete
- User types in the input
- Matching titles are shown
- Clicking a result opens the page
This works fine, but it’s limited for larger result sets.
What I want to add
I want a dedicated search results page, for example:
/search/?q=nexon
Behavior:
-
User types a query and presses Enter
-
User is redirected to
/search/ -
The search page:
- Reads the query from the URL
- Runs FlexSearch
- Displays all matching results
My questions
1. Is creating a search results page the right approach?
Is it better to:
- Keep autocomplete search for quick access
and - Add a full search results page for deeper browsing?
Or should everything be handled only on the search page?
2. Suggested / recommended way in Hugo?
What is the recommended Hugo structure for this?
For example:
- Create
content/search/_index.md - Create
layouts/search/list.html - Load FlexSearch JS only on the search page
Is this the correct approach?
3. Basic implementation steps (high level)
I’m looking for simple guidance, not full code.
For example:
- How to pass the query to the search page
- How to read
?q=from the URL - Whether to reuse the same
index.json - How to handle large result sets cleanly
Goal
- Keep Hugo responsible for static data generation
- Keep FlexSearch responsible for client-side searching
- Have a scalable, maintainable search experience
Any better alternatives?
If there is a better or more standard way to implement search results in Hugo (with or without FlexSearch), I’d appreciate suggestions.