Limit search to a specific folder

I’m trying to configure Fuse.js search on my website following model: https://www.ronaldsvilcins.com/2020/06/09/how-to-implement-search-in-hugo/. In my Content folder I have created folders: Women, Men, Kids etc. A user who is looking for a women shoes, initiates her search on some women page - but Fuse.js searches all content folders and returns Women, Men and Kids shoes. I hope someone can tell me how to confine search to the content folder where search was initiated?

As I understand, I should split current URL, get the 1st element of it and use it in this form instead of absURL:

<form action="{{`search` | absURL }}" class="search-form">
						<input type="search" id="search-query" name="s" class="form-control" placeholder="{{ .Site.Params.banner.placeholder }}" />
						<button type="submit" hidden></button>
					</form>

Thanks a lot!

This looks very much like a question related to using Fuse.js and its capabilities, not Hugo. Simply using technology X with Hugo doesn’t necessarily make it a Hugo question.

If you think there is a bug in Fuse.js, you are free to create an issue on GitHub:

This is a question about splitting URL, isolating its 1st element and using it instead of absURL in {{search | absURL }}.

Please put a working sample repo online and add here, what you expect to see in the action-attribute of the search form (what’s the action url for Women, what’s the url for Men).

I didn’t try out the how-to you linked, but from what I read there and In your initial description: You have three folders (sample):

/content/men
/content/women
/content/kids

and want to know the men, woman, kids part. That would be Sections and there are methods to get .currentSection which might solve your issue.

The way you attempt it I would expect issues further down the road just in case you change URL-layouts or content.

This is a problem I have struggled with. While I have no solution for you, I have discovered that when you make a multilingual site with separate content directories (content/en content/jp) the searches do not range across the whole site anymore. This is very convenient.

So it is possible. I hope you can find the solution!

I found the solution and now I’m working on its implementation. The solution is to assign categories to your items and then you’ll be able to search for an item that belongs to a category. Like in SQL, e.g.: Select employees WHERE language = japanese, in Hugo you can {{range where “language” “japanese” etc.}}

Did you solve this? Can you share your solution with example code?