---
title: "search.tt Template"
url: "https://docs.chinaski.net/en/theming/search-tt/"
type: "page"
language: "en"
description: "How search.tt builds the public search page: the form, live results, and the per-language search-index.json that is filtered in the visitor's browser."
updated: "2026-09-29"
generated: "Markdown rendition of the HTML page at url, built by Chinaski"
---

# search.tt Template

`search.tt` is the public search page of a Chinaski site: a themed, self-contained search built per language, with the search executing entirely in the visitor’s browser. No server processing, no external service: the page fetches a generated JSON index and filters it locally.

## What it renders

- A **search form** (autofocused, `role="search"`): the read/written `q` parameter.
- A live-updating **results region** (`aria-live="polite"` announced to screen reader users), with result count and title-link/excerpt entries each styled by the default theme’s inline search CSS.
- The standard site chrome, header and footer partials, included as usual, with the page **explicitly marked noindex** in its `<head>` (a utility page: search pages never appear in sitemaps or search results).

## How the search behaves

- **Data source**: `<url_base>/search-index.json`, generated per language at build time (one entry per published page/post of that language: title, URL, excerpt). The page fetches this file the first time a query runs and reuses it in-memory afterward.
- **Matching**: substring matching on titles and excerpts (case-insensitivity applied locally); the results list links through the theme’s result items with an excerpt under each hit.
- **Empty states**: “No results for …” text for zero matches; “Search index unavailable.” when the index fetch fails entirely.
- **Sharing queries**: submitting a search rewrites the URL to include `?q=<query>`, so pasting a search URL reproduces the results on load (the initial q is honored when the page renders).
- **Fail-gently**: the count line (“N result(s) for …”) plus the no-hits/no-index messages render inside the results region; the rest of the page (header/footer, navigation) is unaffected.

## Per-language behavior

Search pages build per language: each language has its own `/search/` page and its own `/search-index.json`, so a language’s search never surfaces another language’s content. Results policy carries the same cache implications (a fresh build regenerates the index; the cached copy shows until the next fetch).

## Theme customization

The search page’s inline styling ships in the template. Themes that want different visuals override the `search.tt` file itself: the INCLUDE of the standard header/footer and of `_<head>` stays justifiable under the same template-file structure; with search stylesheet changes shipped in your theme while the index format is fixed.
