FIELD NOTES
← Back to writing
· 4 min read

Search without a search server

Pagefind turns the finished HTML into a small browser-side index, so the site gets useful search without a database or API route.

Search is one of the first features that makes a static site feel incomplete. The content is there, but visitors need a way to find the useful page without knowing its URL.

Pagefind fits the boundary well. It runs after the Astro build, reads the HTML, and writes a set of small index files into the output directory. The browser loads the search interface and requests only the pieces needed for a query.

Index the content, not the furniture

The header and footer are repeated on every page, but they are not useful search results. A data-pagefind-body marker tells the indexer which content belongs to the page. Repeated chrome is marked as ignored.

The same build that validates the content also creates the search index. There is no second service to deploy and no search database to keep in sync.

What the visitor gets

The search page has a normal input, keyboard focus, and a clear action. The top bar links to the same archive and can submit a query directly. A visitor can type a phrase from any page and land on a filtered result list.

The important detail is that search is still a product feature, not merely a script tag. It needs a stable place in the navigation, useful page titles, sensible excerpts, and an empty state that explains what to try next.