I would like to create a separate search page where the user enters a keyword on any page and then jumps to a page like
/search.html to display the results. The place where the user’s search behavior occurs may not be the search page, so I’m currently unsure how to get the search results and pass the data. I can think of a couple of solutions, but they all have problems that I can’t solve:
Get the URL query parameter as a keyword, search using
Generate results with
Fuse.jswhen the user clicks the search button and sets them into
.Site.Scratch, and the next search template gets the data and generates the corresponding results. This seems to work, but I’m not sure how to put the result data into
Forget about the
Fuse.jssearch and create a search myself in the search page template using the JSON data format used by
Fuse.jsand display the results. The problem with this is that I haven’t found any way that allows me to get the URL query parameter for the current page (violate Hugo’s goal as a static site generation tool?), and as a result, I can’t do any searches either.
Will any of the above solutions work if I know more about Hugo? Or is there any workaround that will do the job?