Skip to content

Site Search

Velocity includes site search at /search, built on Pagefind. After each production build, integrations/pagefind.mjs indexes the prerendered HTML and writes a static index next to the site. There’s no search server or API key, and the browser only downloads the index chunks that match the query.

Only content inside data-pagefind-body is indexed. PageLayout and BlogLayout set it, so navigation, footers and LandingLayout pages stay out of results.

To leave a page out, use the searchable prop:

<PageLayout title="Thanks" searchable={false}>
<!-- Not indexed -->
</PageLayout>

To add content from a custom layout, mark it yourself:

<article data-pagefind-body>
<slot />
</article>

Pagefind builds one index per <html lang>, so each language searches its own pages.

The index only exists after a build, so search doesn’t return results in astro dev:

Terminal window
pnpm build && pnpm preview

Remove pagefind() from integrations in astro.config.mjs, delete src/pages/search.astro, src/pages/[lang]/[...search].astro and src/views/SearchView.astro, and remove the search route and nav item from nav.config.ts.