#4229: search.json

site/search.json

Path: site/search.json · Lines: 14 · Front matter: layout: null

Purpose: Jekyll Liquid template that generates a static JSON search index at build time — consumed by Tipue Search JavaScript on the client side for documentation search without any server infrastructure.

Source: GitHub

14 lines · 14 code · 0 comments · 0 blank
CommitMessage
ac75fabf3Github pages migrated to Asciidoc

How static search works — the Jekyll+Tipseearch architecture

This file is NOT a static JSON file — it's a Jekyll template processed at build time. The workflow:

  1. Build time: Jekyll processes {% for doc in site.docs %} — iterates every document in the _docs/ collection (installation.adoc, userguide.adoc, development.adoc, etc.) — and generates a static search.json file in the output directory.
  2. Runtime: When a user types in the search box on /search/ (#4093), the Tipue Search jQuery plugin fetches /search.json, filters entries client-side, and renders results — no server, no database, no API.

This is static site search — the entire searchable corpus is a single pre-computed JSON file. Fast, cheap, but doesn't scale beyond a few hundred pages.

---
layout: null         # Critical: without this, JSON would be wrapped in HTML
---
[
  {% for doc in site.docs %}
    {
      "title": "{{ doc.title | escape }}",
      "category": "{{ doc.category }}",
      "tags": "{{ doc.tags | join: ', ' }}",
      "url": "{{ site.baseurl }}{{ doc.url }}",
      "date": "{{ doc.date }}"
    } {% unless forloop.last %},{% endunless %}
  {% endfor %}
]

layout: null: Without this, Jekyll wraps the JSON in the site's HTML template (header, nav, footer) — producing invalid JSON. The null layout outputs raw content.

{% unless forloop.last %},{% endunless %}: Adds commas between array elements but NOT after the last element. A trailing comma would produce invalid JSON. Liquid has no built-in "generate valid JSON" filter — this manual comma control is necessary.

Limitations: Only the site.docs collection is indexed — blog posts, FAQs, and changelogs are NOT searchable. Only title/tag matching — no full-text search of document content. All metadata loaded into the browser on first search — not scalable to thousands of pages.