Introduction: Jekyll is a static HTML generation tool. Our documentation system is deployed with Jekyll, which ultimately converts Markdown into HTML files for output.
The search requirement is: given a keyword, match it against a document’s title or content and list the matching documents.
1. Option One: Simple-Jekyll-Search
Reference: https://github.com/christian-fei/Simple-Jekyll-Search
Search scope: article titles
Implementation:
- In the demo, generate metadata of titles plus URLs into search.json through configuration parameters.
- On the frontend, use the keyword to match article titles in search.json and display the search list.
Pros: simple-jekyll-search is available on the backend and jekyll-search.js on the frontend. Low cost.
Cons: It can only search article titles; even if it could search Tags and Keywords, that would still not be enough.
2. Option Two: Searchyll + Elasticsearch
Reference: http://allizad.com/2016/05/06/elasticserch-for-jekyll/
Search scope: article content
Implementation:
- Start an Elasticsearch service locally.
- Install Searchyll, and during the static file generation stage, use a Hook to send the complete HTML to Elasticsearch.
- On the frontend, send the request keyword to Elasticsearch and display the returned list.
Pros: Broad search scope, which basically meets the requirement. Even with many articles, search performance is not affected much. Many Jekyll sites abroad use third-party Elasticsearch services.
Cons: It requires an additional service, which carries some maintenance cost.
3. Option Three: Custom Search with Content Loaded into a Database
Search scope: article content + titles
Implementation:
- Load static pages into a database with Python
- The frontend sends a keyword to the backend, the backend queries the database, and returns the list of matching articles
Pros: Search can be customized.
Cons: The documentation is updated frequently, so the data needs to be refreshed in sync.
