Simple Hugo search using JSON file

It’s great to see things like this. Well done. You might interested to know that someone posted a similar search function a couple of years ago. I’ve used that one and found it very handy and easy to set up too.

I think your solution may also require another config file change to allow HTML in Markdown files though:

[markup]
    [markup.goldmark.renderer]
      unsafe = true

As I understand it this is fine for personal sites but not such a good idea where other people are edting the site as a stray bit of malformed HTML could mess up the whole page layout.

A safer alternative would be to leave out the above config code (so then the default unsafe=false is set) and add the HTML to a shortcode and then use that in the Search page markdown file. Or just use an HTML file instead perhaps.

Anyway good job making and sharing this and I will give it try next time I need a search like this.

1 Like