Site Search — Implementation Plan

Goal: Let visitors search across all WatchTheStars pages and posts (~300 pages: 108 blog posts + ~190 other pages).

Chosen approach: Pagefind — a static-site search library that indexes the built HTML at deploy time and runs entirely in the browser. No backend, no third-party account, no cost. Fits the existing Eleventy + Cloudflare Pages "build and push" workflow.

(This is a planning doc for review — it lives at the repo root and should not be deployed. Delete or move it once we've agreed the approach.)


Why Pagefind (vs. the alternatives)

Option Verdict
Pagefind ✅ Auto-indexes built HTML, downloads index in small chunks per query, ships a themeable UI, zero backend/cost. Best fit.
Lunr.js / Fuse.js ❌ Loads the whole index upfront; doesn't scale well past ~100 pages; hand-rolled indexing + UI.
Algolia DocSearch ⚠️ Powerful + free tier, but adds an external account, a crawler to configure, and a dependency. Overkill here.
Cloudflare Worker + D1/Vectorize ⚠️ Only worth it for true semantic search; real backend to build + maintain. Park as a future enhancement.

How it slots into the current build

Current chain (run by Cloudflare on every push to main):

npm run build   →  eleventy  (renders _site/)
                →  postbuild: node scripts/minify.mjs  (PurgeCSS + clean-css + terser on _site/)

Pagefind runs last, after minify, so:

New chain:

npm run build   →  eleventy
                →  postbuild: node scripts/minify.mjs && npx pagefind --site _site

Implementation steps

1. Add the dependency

2. Tell Pagefind what to index (the quality step)

By default Pagefind indexes the whole <body>, which would pull in nav, footer, and the email signup widgets — noisy results. Fix by editing the shared layouts:

3. Add the search UI

4. Optional polish (v2, not required for launch)

5. Test before deploy

6. Deploy


What this changes / watch-items


Rough effort

Roughly half a day end-to-end: ~1 hr wiring the build + dependency, ~1–2 hrs on layout data-pagefind-* attributes and the nav UI/styling, the rest on testing across page types. The optional v2 polish is separate.

Open questions for Ian

  1. Placement — search icon in the main nav bar (my default), or also a bigger search box on the homepage / blog index?
  2. Scope — index everything (all 300 pages), or restrict to blog posts + key hub pages?
  3. v2 filters — do you want the astronomy/UAP category filter and GA4 search tracking now, or launch simple first?