This page looks best with JavaScript enabled

Jekyll Search Options

 ·  ☕ 2 min read

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.

Reference: https://github.com/christian-fei/Simple-Jekyll-Search

Search scope: article titles

Implementation:

  1. In the demo, generate metadata of titles plus URLs into search.json through configuration parameters.
  2. 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:

  1. Start an Elasticsearch service locally.
  2. Install Searchyll, and during the static file generation stage, use a Hook to send the complete HTML to Elasticsearch.
  3. 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:

  1. Load static pages into a database with Python
  2. 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.


WeChat Official Account
WRITTEN BY
WeChat Official Account