How are you implementing site search

Yes. I know I’m getting to be a bit like a dog with a bone about this. But it’s driving me mad. Today, I was trying to find some info for someone on one of the blogs where I implemented DuckDuckGo Search way back [according to my first posts in this thread] in March 2016. That’s a full two years ago!

…and it’s still returning results pointing to URLs which date from the time the blog was hosted on WordPress, which is even longer ago than that. This is in spite of the fact that I have submitted XML sitemaps to Yandex [who power DDG Search] on numerous occasions and jumped through every “webmaster” hoop they offer.

How can a search engine be so bad at updating its index? As I’ve said ad nauseam Google updates search results for my sites almost instantly without me doing anything. DuckDuckGo / Yandex can’t even do it when given over two years and me guiding them along the way!

Here are the results for searching for ‘gear linkage’ on the site. The top two results are URLs from prior to March 2016, when the site was running on WordPress. It’s not til the 3rd and 4th results that we get a couple of the newer Hugo URLs. This mess carries on throughout all the search results for any search made on the site.

Funny that this thread is revived just about as I am done adding (finally) search to my site. I just posted about that here:

Spoiler: This Fuse.js method for implementing the site is very simple, and works great! :smiley:

3 Likes

Fuse is cool and it’s very fast. My only gripe so far is that it’s not designed for exact matches. In other words, if the user searches for privacy policy and the JSON blob contains items with privacy or policy those’ll be returned in the result set.

Interested in seeing a vanilla JS implementation which filters the Fuse result set for an optional exact match.

UPDATE: Rolled a vanilla implementation. After Dark now supports fuzzy search with Fuse. See the After Dark docs for more info.

Demo time: https://hackcabin.com/search/?s=secure

I have implemented client side search engine without using any backend server or any additional steps by following https://gist.github.com/eddiewebb/735feb48f50f0ddd65ae5606a1cb41ae for my website.

I have also created an article to clearly explain the steps I followed to implement search engine, which might help some of you:-

4 Likes

Thanks for sharing this! I’ve just had a look through your implementation and trying it out on my staging site (https://staging.cloudwithchris.com)

Have you been able to inject Hugo Partials into those templates? I’m assuming it’s not possible given it looks to be rendering from the search.js file rather than Hugo directly. Given that, I’m trying to recreate some of my partials (e.g. labels for the tags, linking back to the appropriate taxonomy page). I wondered if you had to solve/encounter those challenges at all? cheers!