Mastodon hachyterm.io

Hugo is a well-designed and feature-full static site generator. It’s ideal for a blog.

The build times are fast, so it’s a joy to write a blog post with the development server and enjoy fast reloading.

Unfortunately, it’s not easy to integrate a search function with Hugo.
You definitely need a third party, either a commercial service like Algolia, or a NPM library like lunr.js.

I do not want to add a commercial service. And it’s also quite a hassle to integrate the search functionality into the Hugo site if you don’t want to add yet another JavaScript library.

To be fair, Algolia offers instant search and you can add analytics to your site.

Lunar.js also requires you to deal with NPM. You first have to build an index of your website, then wire up Lunr.js, then connect it to Hugo.
The hugo-lunr package is abandoned.

Enter Duckduckgo.

Duckduckgo is focussed on privacy and their search results work fine.

You can easily integrate a search box into your website with a bit of HTML:

<form method="get" id="search" action="http://duckduckgo.com/">
  <input type="hidden" name="sites" value="YOURDOMAIN.COM"/>
  <input type="hidden" name="k8" value="#444444"/>
  <input type="hidden" name="k9" value="#D51920"/>
  <input type="hidden" name="kt" value="h"/>
  <input type="text" name="q" maxlength="255" placeholder="Search&hellip;"/>
  <input type="submit" value="DuckDuckGo Search" style="visibility: hidden;" />
</form>

Further Reading