№ 13 Field manual

Search on a static site: a search box with no server

Operations · Updated 23 November 2026 · 6 min read

The short version
  1. 01Search needs an index, a query, and a ranking. A static site has no server, so the browser does all three.
  2. 02Four shapes exist: an index inside the page, an index file, an outside service, and your app’s own database. The first fits a small site.
  3. 03Every page in the index is a published link. A page you want private must stay out of it.
  4. 04A search box is a briefed change. You describe it, an agent opens the pull request, and a person merges it.

Search needs an index

A search box does three jobs. It holds an index: a list of what the site contains. It takes a query: the words a visitor types. It applies a ranking: the rule that puts the best match first.

A server-based site runs all three jobs on the server. A static site has no server. So the index must reach the visitor’s browser, and the browser runs the query and the ranking. The next section shows four ways to do that.

The four shapes differ in where the index lives and where the query runs:

ShapeWhere the index livesWhere the query runsWorks on a static site?What it addsWhen it fits
The index inside the pageIn the HTML of one search page.In the visitor’s browser.Yes.Bytes on that one page. Each entry adds to its weight.A small site. The page stays inside its byte budget.
An index fileIn a file built at each deploy.In the visitor’s browser, after the file loads.Yes.One more request when the visitor starts to type. The page itself stays light.A site whose index no longer fits inside a page.
An outside search serviceAt the service.At the service.Yes, from the visitor’s browser.Treat it as an embed. A widget, a tracking pixel, or an embed is a request to a server we do not run. No page-weight budget of ours can cap what it costs a visitor.A very large site, or one that needs ranking you cannot build.
Your app’s own database searchIn your database.On your Dedicated S instance.No. A static site has no database.A dedicated instance, from $29/mo, and a database, from $12/mo.An app that already keeps its content in a database.

The outside service has one trap. A service often gives you an admin key and a search-only key. The admin key is a secret: a value that grants access, and must not leak — to a person, a log, or a public bundle. So it must never enter a build. No standing server, so nothing here can hold a secret at all. A call to an outside service has to run from the visitor's own browser, out in the open. That's fine for a map or a widget. Never for a payment key. Only the search-only key may reach the browser. See outside services for the whole boundary.

Do you need a form instead? See forms. Do you need a database? See databases.

Everything in the index is public

An index is a list of links. Every page in it is a published page. Anyone can read the index in the page source and open every address in it.

So choose the index from the pages you already publish. This site does that. Its index comes from the route list in manifest.ts, the same list that builds llms.txt. Nothing enters search that the site does not already publish.

A private page must stay out of the index. A search box does not hide a page. To close a page, read keeping a site private.

Fresh as the last deploy

The index builds with the site. So the content and the index ship together in one deploy. No separate job refreshes it, and no second copy can fall behind.

A page change rebuilds the index. A new page appears in search when its deploy finishes, not before. The search never shows a page that the site does not serve.

This site has one

This site has a search box at /search. It uses the first shape. Every figure below comes from the build, not from a person.

  • 369 entries. 108 pages, 162 glossary terms, 92 guide sections, 7 answers.
  • 43.5 KB on the wire. The page is 38.8 KB of HTML, in 3 requests. The budget for any page is 60.0 KB. This is the heaviest page on the site.
  • About 90 bytes an entry. That figure leaves out the page frame that every page carries. The room left is 16.5 KB. That is about 188 more entries before the page crosses its budget. After that, move to an index file.
  • A plain form. The box is a search landmark. It sends a GET request to /search with the word in q. The address keeps the query, so a visitor can share a result.
  • A live count. The result count sits in a live region, so a screen reader announces it.
  • It works with no script. With JavaScript off, the page shows the full list. The filter runs in the page. It makes no call to a server.

check:search checks these claims against the built site. It counts the rows, reads the form, and fails if the page script calls a server.

What it does not do

  • It does not forgive a typo. Each word you type must appear in the entry as you typed it. A misspelling finds nothing.
  • It does not know word forms. It does not reduce a word to its stem. A plural you type finds nothing when the entry only holds the singular.
  • It ranks on two levels. A match in the entry’s title comes first. Every other match follows, in the index’s own order.
  • It reads a summary, not the whole page. The index holds each entry’s title, description and keywords. It does not hold the full text.
  • A typed query can reach analytics. The analytics tag on this site loads on every page. It can see a /search?q= address when a visitor opens one directly. See the privacy page for what the tag collects.

A search engine is a different thing. It finds your site from outside. See being found for that half. See performance for the byte budget.

Asking for it

A search box is a briefed change, not a switch. CodeHerder carries it. This is how one change ships:

  1. You describe the search. Write one line: add a search box to the site. Say what a visitor looks for, and which pages must stay out of the index.
  2. The brief is read for size. The agent counts your pages and picks a shape. A small site gets the index inside the page. A larger one gets an index file.
  3. Briefed as a change. Written up the same way any other change request is. The iteration add-on is what covers it.
  4. An agent opens the pull request. The change lands as a real pull request against the repository, with the test suite run against it.
  5. A human reviews and merges. Someone reads the diff before it goes anywhere near production — nothing here is auto-applied blind.
  6. It ships through the same pipeline. The same pipeline that deploys everything else on your stack ships this too — no separate process to babysit.
  7. You're told it's done. A note confirming what changed and that it merged, in the same shape as every other note on this site.

CodeHerder is $25/mo on any plan. A search box on a static site fits the Static Starter plan at $5/mo. Quote this shape. The form opens with this plan and add-on filled in.

Your app may need search over its own data. CustomLabs builds that, on a dedicated instance with a database.

Ready to start?

Tell us what you're running — one fixed monthly rate, within a business day.

Get a quote →