How to search in a Hugo site


I have just now got done creating this new section on my website.

I would like to implement a search feature to search through the site.

No idea how to do that.

I was thinking, is there a way that Hugo can give me all the URLs it generates, excluding the aliases, that I can put into JSON, then using JS in front end, have a search field that searches through the JSON data for a fuzzy match or something, and returns a list of URLs which I can render to the user upon search?

I don’t want to do Google custom search.

If Hugo can give me the list of URLs, or you guys can help me figure out how to get those, I can then go from there and code something in JS, minimally, not have to depend on even some lib.

What do you guys do? Ideas? Opinions?

I noticed that when I shared the link here, discourse did not show the image. It shows a broken image.

However, this image exists

FB Debugger shows the og image just fine, as well as FB.

EDIT: Reloading didn’t help. So I went back, refreshed, then clicked on the thread again and now it shows up fine. Weird. Anyway.

Any ideas about the search thing?

I mean, it’s basic, only looking through slugs for keyword, which is not the best way to search. Ideas?

The docs outline search options, both native Hugo (JSON) and third party.

1 Like

Brilliant. I didn’t even know about this section on docs! Thanks.

The docs are generated by Hugo, and has search.

This is the simplest, quickest iteration on search I could come up with: