matsuyoshi30 / harbor

Simple and minimal personal blog theme.
MIT License
187 stars 67 forks source link

Search doesn't work #100

Open rempas opened 3 years ago

rempas commented 3 years ago

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.

kaakaa commented 3 years ago

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/