4 ms·
How do you handle search?
by justaguyhere 6y ago
How do you handle search?
- seriocomic 6y agoSearch and comments are the casualties of static-sites - unless you bow and crumble to the use of something 3rd party (Disqus or Google Site Search to name some poor examples)
- justaguyhere 6y agoComments are not as important as search, I guess. If the site has tons of pages, not having search might be annoying to the user
- vidar 6y agoCan't you point algolia at a static site and get decent search or have I misunderstood?
- andreasha 6y agoYou can check out Lunr. The Jekyll theme Minimal Mistakes has that as a search option and builds a JSON index file. The demo site uses Algolia though https://mmistakes.github.io/minimal-mistakes/ https://mmistakes.github.io/minimal-mistakes/
- jeromenerf 6y agoHugo provides a Json output that can be used by a js script to provide simple search. I guess the same is possible for other systems. Comments, contact forms and other features that "creates" content are more difficult.
- clairity 6y agostaticman[0] for comments is a neat solution that avoids those surveillance companies. it can use heroku hobby tier for processing and github as the content backend for a free, hosted comments solution for static sites (fully acknowledging that heroku and github are both owned by other surveillers). [0]: https://github.com/eduardoboucas/staticman https://github.com/eduardoboucas/staticman
- Uehreka 6y agoCan’t speak for GP, but I have a static site written in Gatsby. Yes (prepares boring-to-mention downvote armor) it is absolutely riddled with JavaScript. But if you want the ability to “search” without having a backend, Gatsby can do that.
- madbkarim 6y agoMay I know how do you do that?
- Uehreka 6y agoHere’s some docs from their site: https://www.gatsbyjs.com/docs/adding-search/#reach-skip-nav https://www.gatsbyjs.com/docs/adding-search/#reach-skip-nav But they assume some context, which I’ll give you: At compile time, Gatsby is capable of making a list of all the posts on your site that you can query with GraphQL (at compile time) or use in the JS of your pages. In fact, saying it makes a list of all “posts” is selling it short, because Gatsby can store and manipulate arbitrary data structures. So if you’ve got a Documentation site with a table of contents and three levels of content within it... that’s all queryable at compile time too. It’s extremely flexible. Now, it’s not like your pages will actually be using GraphQL to query a DB when the user arrives on the page: all the data is basically “baked in” to the page when it is compiled. But for a static site where the “data” only changes when you add/change some content and recompile, this works really well.
- madbkarim 6y agoThat’s great thank you!
- SnowingXIV 6y agoFor a lot of situations something like jekyll search [0] works wonders. It basically generates a json file (you can customize it quite a bit). For even decently sized blogs it's quite quick and doesn't require a page refresh. [0] https://github.com/christian-fei/Simple-Jekyll-Search https://github.com/christian-fei/Simple-Jekyll-Search
- greggyb 6y agoHTML form to jam the search string into a format like below (: https://duckduckgo.com/?q=site%3Ayour-site.tld+the+user+search+string