Constrain search to sub-directory e.g. with fuse.js

My setup
I use Hugo with Geekdocs to run a medium sized technical documentation. The site is not connected to the public internet. The structure is a tree of markdown files in the content directory.

What I look for
Geekdoc has a search feature for the whole web site. However, I’d like to have a (seperate) search bar which only searches the currently open section (section is the name for a sub-folder in Hugo). The looks I imagine would be similar to Docsy. This forum has the same feature, I just noticed.

How can I achieve that?

What I tried until now
My idea was to include fastsearch and configure it the way I like. Fastsearch is up and running. Now, I’m not sure how to proceed.

The first try was to edit the template for index.json to only include the current folder. But I’m suspecting this to be a wrong approach, because the file is a static file, if I understand correctly.

Maybe it is possible to include this function in JavaScript, but I have never used that before. So before I would dive into JS, I’d like to kindly ask, if anyone already has a solution for a sub-directory i.e. section-scope search feature.

A “sub directory” in GoHugo is a section. You probably create your search index somewhere and add some parameters per page. If you add your section as a parameter there then you can filter with whatever search library you are using. fuse.js does not sound like a GoHugo feature, maybe asking in their dedicated forum might help. You can add as much information as you want to your search index. Just add sections, kinds, types, etc so you can filter based on those.

1 Like

Thanks for clearification.
So it is a valid way of doing things to add different index files for different sections?