$0 Infrastructure Cost
There is no cloud database or monthly SaaS bill. The entire search index compiles into static static files hosted directly on GitHub Pages.
Search is the primary navigation mechanism for technical documentation. When a developer or writer visits a knowledge base, they rarely browse through hierarchical trees; they press Cmd+K and type keywords.
Historically, implementing full-text search in static documentation required integrating hosted SaaS search engines (like Algolia DocSearch, Swiftype, or Elasticsearch). While effective, these services introduce recurring infrastructure costs, crawler indexing delays, API key management, and data privacy concerns.
This documentation blueprint eliminates third-party dependencies by utilizing Pagefind—a state-of-the-art, zero-backend, static WebAssembly search engine.
$0 Infrastructure Cost
There is no cloud database or monthly SaaS bill. The entire search index compiles into static static files hosted directly on GitHub Pages.
Instant Indexing (Zero Delay)
Unlike web crawler bots that may take hours or days to re-index changed documentation, Pagefind generates its index in milliseconds during npm run build.
Sub-10ms Search Latency
Compiled WebAssembly runs directly inside the reader’s browser, fetching chunked index files over standard HTTP range requests.
100% Data Privacy
Reader search queries never leave their browser. No tracking pixels, external API logs, or analytics bots monitor internal search terms.
When you run npm run build, Astro and Pagefind execute a two-stage compilation pipeline:
[ 1. Astro Build ] [ 2. Pagefind Indexing ] [ 3. Deployment ]MDX Files -> HTML in /dist ---> HTML Scanned -> WASM in /dist/pagefind ---> Pushed to CDN / GitHub Pages./dist folder../dist. Pagefind parses heading structures, text bodies, and metadata..pf_fragment and .pf_index) and generates the WebAssembly runtime files inside ./dist/pagefind/.16:58:00 [build] ✓ Completed in 1.79s.16:58:00 [starlight:pagefind] Building search index with Pagefind...16:58:00 [starlight:pagefind] Found 38 HTML files.16:58:00 [starlight:pagefind] Finished building search index in 74ms.16:58:00 [@astrojs/sitemap] `sitemap-index.xml` created at `dist`When a user visits our documentation and opens the search dialog (Cmd+K):
The browser downloads a lightweight WebAssembly binary (~30 KB gzip). It initializes instantly without impacting initial page load performance.
As the user types letters, Pagefind uses HTTP range requests to download only the specific index chunks containing the matching words, rather than downloading the entire multi-megabyte site index.
Pagefind scores results locally based on term frequency, heading depth, and proximity, displaying highlighted excerpts and direct section links in real time.
Starlight automatically configures Pagefind’s indexing rules, but technical writers and developers can fine-tune what gets indexed using HTML data attributes:
| Attribute | Behavior | Where to use |
|---|---|---|
data-pagefind-body |
Explicitly marks the container element as the primary searchable text body. | Starlight injects this automatically on the <main> article wrapper. |
data-pagefind-ignore |
Completely excludes an element and its children from the search index. | Used on navigation sidebars, breadcrumbs, and “Behind the Curtain” tabs. |
data-pagefind-weight |
Multiplies the ranking relevance of a heading or block. | Starlight automatically assigns higher weights to H1 and H2 titles. |
Because Pagefind compiles directly from compiled static HTML rather than raw Markdown, it natively supports: