harbor icon indicating copy to clipboard operation
harbor copied to clipboard

Search doesn't work

Open rempas opened this issue 5 years ago • 1 comments

I don't know if I'm doing something wrong but search doesn't work for me. I got the page and I can type in the box but I get no results.

rempas avatar Apr 04 '21 09:04 rempas

In my case, the reason why search doesn't work was missing /post/index.json.

スクリーンショット 2021-06-19 7 07 34

index.json is like this and it's referred in search.js.

index.json, which contains metadata for all post of type post, should be make automatically from layout list.json (if you specified [outputs] section = ["json", "html"] in config.toml). But in my case, index.json didn't contain any valid metadata because I wrote entries in content/posts and my all entries has type posts, not post. After moving all entries from content/posts to content/post, search got to work fine.

The following article might help to find out how search feature works. https://janikvonrotz.ch/2019/06/10/2019-06-10-simple-hugo-page-search-with-lunrjs/

kaakaa avatar Jun 18 '21 22:06 kaakaa