I just added static search to this website, and it is super easy. (see /search )
How does it work?
- we create one big json with all the page content (index.json).
Every page is summarized into title, summary, content and tags.
How can I add it too?
I followed the guidance here: on the hugo discourse website. Add the following things to the website:
- a shortcode in layouts/shortcodes/search.html
- a page for search: content/search.md
- a custom layout that creates a json in layouts/index.json
- Modify the config.toml to also produce json for the main page:
[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