Search
The theme ships with two complementary search indexes: Pagefind for prose (full-text search across the site) and a fuzzysort-backed index for API symbols (instant lookup by name). Both are static — they live in files written next to the built site — so the deployed app has no backend to host.
Prose search
Pagefind runs as the
last step of every build. It walks the emitted HTML, extracts text
from each page, and writes its index under
_site/assets/apidocs/pagefind/. At runtime the search dialog loads the
shards it needs on demand — opening search costs a few kilobytes,
not a full index download.
What gets indexed
Pagefind indexes the element marked
data-pagefind-body. The layout puts that attribute on
the <main> wrapper, so the article content is
indexed and the header, nav, ToC, and footer are not.
Inside the indexed region, sub-results are anchored to the nearest
id-bearing element — usually an
<h2>–<h5>. A search hit
opens the page scrolled to that heading.
Excluding content
Mark anything you want Pagefind to skip with
data-pagefind-ignore. The theme uses it on the
prev/next footer so navigation labels don’t show up as
spurious search hits. Use it on parts of an article that aren’t
useful in results — large code blocks, embedded JSON,
boilerplate aside notes:
<pre data-pagefind-ignore data-language="json">
{ "very": "long", "fixture": "data" }
</pre>API symbols
For API documentation, the prose index is the wrong shape —
you want to type a method or option name and jump straight to its
page. The theme harvests every .api element during the
build and writes the manifest to symbols.json at the
site root.
The search dialog lazy-loads symbols.json the first time
you focus the symbol panel, then queries it through
fuzzysort.
Matches are scored and ranked client-side, so typing is responsive
even on a large API surface.
See API reference style → The symbol index for the entry shape and how to control what gets harvested.
The search UI
The search box in the header opens a modal with two panels: prose results from Pagefind on the left, symbol matches from fuzzysort on the right. Keyboard shortcuts:
| Key | Effect |
|---|---|
| / or Ctrl+K | Open search from anywhere on the site. |
| ↑ / ↓ | Move selection through the results. |
| Enter | Open the highlighted result. |
| Esc | Close the dialog. |
Rebuilding the index
Both indexes are produced by pnpm build:
-
symbols.jsonis written from the symbol accumulator threaded through every page’s pipeline. -
Pagefind’s
assets/apidocs/pagefind/directory is generated bycreateIndex({}).addDirectory({ path: _site })running after Eleventy is done writing files.
In pnpm dev, the symbol and Pagefind indexes are built once
at start-up and then reused for the rest of the dev server’s
lifetime — reindexing the whole site on every keystroke is the
dominant per-build cost, so later rebuilds skip it. Search reflects the
start-up snapshot; restart the dev server (or run a full
pnpm build) to pick up content you’ve since edited.
Because the indexes are frozen at start-up, a symbol or passage you add mid-session won’t appear in search until you restart the dev server. The search UI degrades gracefully when an index is stale or missing, so the page itself keeps working in the meantime.