Now while I’ll be the first to admit this will probably be outside the scope of Hugo’s intended purpose, there are benefits to having search built into Hugo without having to use JS. This obviously won’t work if serving the content using NGINX or another web server, unless someone builds an external cross-platform app just for searching. I personally would like to see this, but ideally site search using JSON would be better as part of the browser itself.
However, I am looking to distribute my site using Git and hopefully have users serve the content locally using Hugo Server. Therefore, this could be part of the Hugo Server. Using the key/value and Hugo you could even filter searches based on specific keys or sections of a site. Additionally, Hugo Server could be made fully “production” ready, if it isn’t already.
There may be a way to create a placeholder for another search server, and then have it populate the search results within the Hugo template, but I’m not having any luck finding an easy to implement solution. If anyone has suggestions on how to do this, please let me know.
Second lunr.js. It’s super simple to implement and does work within the development server provided by
For Hugo to provide search processing as a back end server, it would also need to create the results page(s) based on that search, which means creating The Hugo Way to do search and making people build templates that fit that. Also, that would be creating dynamic sites (since the result pages are built just before sending them to the user), which would go against Hugo being a static site generator.
Hugo server is really meant to test site changes before they get published and should remain limited to that, IMO. There are plenty of good static file servers out there - Hugo’s devs don’t need to split their focus by implementing one too.