Adding Static Search to Page

Roel M. Hogervorst

2020/11/02

Categories: other Tags: 100DaysToOffload search javascript hugo

a loupe on a macbook, because why not

I just added static search to this website, and it is super easy. (see /search )

How does it work?

Every page is summarized into title, summary, content and tags.

The logic in that javascript matches the keywords against the content of the pages. You can even modify the relative weights of the search parts.

How can I add it too?

I followed the guidance here: on the hugo discourse website. Add the following things to the website:

[outputs]
   home = [ "HTML", "JSON" ]

I tried it out and it worked out of the box! The only thing I modified was the search.html shortcode because it used German words for AND / OR search.

I’m publishing this as part of 100 Days To Offload. You can join in yourself by visiting https://100daystooffload.com, post - 38/100

Find other posts tagged #100DaysToOffload here

Image from unsplash by Agence Olloweb