Skip to content
✨ Publier v1 is live — a polished docs platform built for the open web.
On this page

Search

What Publier's built-in search indexes, how to scope it, and which files a host must serve.

Publier’s search is Pagefind. The build writes a static index next to your HTML, and the reader’s browser searches it. There is no search server. This page covers what ends up in the index, how to scope it, and what a host must serve. For checking search after a deploy, see Maintain Content and Search.

Two parts, wired separately

PartWhat it doesWhere you configure it
IndexerRuns after the Astro build, reads the HTML in dist/, writes dist/pagefind/The pagefind() integration from astro-pagefind in astro.config.ts
DialogThe Cmd/Ctrl+K dialog and the header search button, loaded from /pagefind/docsShell() and publier.config.yaml

docsShell() supplies the dialog but does not register the indexer. List pagefind() after docsShell(), as the scaffold does:

astro.config.ts
integrations: [
docsShell(),
expressiveCode(),
mdx(),
sitemap(),
pagefind(),
// …
],

Turn search on or off

Three controls exist, and they are independent:

ControlEffect
search.enabled in publier.config.yaml (default true)Shows the header search button.
docsShell({ search: false })Stops docsShell() from loading the dialog and button scripts.
Removing pagefind()Stops the build from writing the index.
publier.config.yaml
search:
enabled: true
hotkey: k

To remove search completely, use all three. Each one alone leaves something behind:

  • search.enabled: false hides the button only. The dialog script is still loaded, so Cmd/Ctrl+K still opens it.
  • docsShell({ search: false }) leaves the header button in place, where it does nothing, and the indexer still writes dist/pagefind/.
  • Removing pagefind() leaves a dialog that opens and shows “Search is temporarily unavailable. Please try again.”, because /pagefind/pagefind-ui.js is not there to load.

search.hotkey sets the shortcut that opens search. With hotkey: j, Cmd/Ctrl+J opens search, Cmd/Ctrl+K no longer does, and the search button shows ⌘J. The value must be a single letter or digit; anything else fails the build with an error naming search.hotkey. A key the browser already uses with Cmd/Ctrl, such as c, v or a, is taken over by search on your site, so pick another.

search.versions is current (the default) or all. With current, a search opened on a page in a declared version returns that version’s pages and pages that belong to no version, including your own pages that carry data-pagefind-body; with all, every version is returned. Any other value fails the build with an error naming search.versions. See Version lifecycle.

search.products is current (the default) or all, and scopes search by product in the same way. See Search scope by product below.

The dialog opens Pagefind’s default UI with fixed options: sub-results on, images off, excerpts of 15 words. None of these is configurable from publier.config.yaml.

What gets indexed

Pagefind reads every HTML file in dist/. Its rule for scoping is the one to know: once any page on the site carries a data-pagefind-body attribute, Pagefind skips every page that does not.

Publier’s docs layout puts data-pagefind-body on the <main> element of every page under /docs/. No other Publier layout or route sets it. In practice:

Page typeIn the index?
Pages from the docs collectionYes. The text inside <main> is indexed.
Blog posts and the blog indexNo
ChangelogNo
Your own .astro pages, such as a home or pricing pageNo, unless you add data-pagefind-body to them

Within a docs page, the sidebar, table of contents, header and footer sit outside <main>. The breadcrumb and last-updated row inside <main> carries data-pagefind-ignore, so breadcrumbs do not appear in snippets. Pagefind also skips elements such as nav, footer, script and form on its own.

To put a custom page in search, tag its main content area:

src/pages/guide.astro
<main data-pagefind-body>
<h1>Field guide</h1>
<p>Searchable text.</p>
</main>

Part of a page

Add data-pagefind-ignore to an element. Its text and everything inside it stay out of the index. In MDX, write the element as JSX:

src/content/docs/reference.mdx
<div data-pagefind-ignore="index">
Repeated text that should not appear in search snippets.
</div>

The value index is Pagefind’s default. The other value, all, also skips filters and metadata inside the element. Content inside the element is also left out of Publier’s rendered Markdown exports, because those honour data-pagefind-ignore too. This is a publication control, not access control: the HTML is still served.

A whole page

  • draft: true in the frontmatter. A draft is not built for production, so it is absent from search, the sitemap and the exports. It remains available in publier dev.
  • Ignoring the body is not the same as leaving the page out. A page whose body sits inside data-pagefind-ignore can still be returned if other text, such as its heading, remains in <main>.
  • sidebar.hidden: true hides a page from the sidebar only. The page is still built and still indexed.

Elements by CSS selector

pagefind() accepts an indexConfig object and passes it to Pagefind’s Node API createIndex:

astro.config.ts
pagefind({
indexConfig: { excludeSelectors: ['.release-table'] },
}),

The Pagefind Node API lists the other keys, such as rootSelector and forceLanguage. The integration calls addDirectory with the output directory only, so Pagefind’s glob option is not reachable through it.

A page with <meta name="robots" content="noindex"> (or none) is left out of the site’s reader search, and out of llms.txt, llms-full.txt and the per-page Markdown exports. The page is still built and served; only its search entry is dropped. For a docs page you can set the tag in frontmatter with head.

This relies on docsShell() being listed before pagefind() in integrations, which is the documented order. The build prints a warning when the order is wrong, so a page you meant to hide is not silently searchable.

How the index ships

The indexer runs in Astro’s astro:build:done step. It writes a pagefind/ directory inside the build output. A Pagefind bundle contains:

  • pagefind-entry.json, the entry point the search code reads first
  • pagefind.js, pagefind-worker.js, wasm.*.pagefind and the highlight script, which run the search
  • pagefind-ui.js and pagefind-ui.css, the default UI that Publier’s dialog loads on first open
  • pagefind-component-ui.* and pagefind-modular-ui.*, additional UI bundles that Publier’s dialog does not load
  • index/ and fragment/, the search data, with hashed file names

A host needs to:

  • Serve dist/pagefind/ at /pagefind/ on the site’s domain root. The dialog requests /pagefind/pagefind-ui.js and /pagefind/pagefind-ui.css at those fixed URLs. Hosting under a subpath is not qualified; see Deployment.
  • Publish it with the HTML from the same build. The index lists URLs and snippets from that build.
  • Allow WebAssembly in your Content Security Policy if you set one: script-src 'wasm-unsafe-eval'. Pagefind’s hosting notes also say a policy that restricts workers may need worker-src 'self' blob:.

Pagefind compresses its own files and its hosting notes say no hosting configuration is required, so no gzip setup is needed.

How publier.net serves it

This site serves dist/ with a small Bun static server. It has no search-specific route: /pagefind/… resolves like any other file in dist/. Its Content Security Policy includes 'wasm-unsafe-eval'. Files under /pagefind/ get cache-control: public, max-age=0, must-revalidate, because only the /_astro/, /assets/, /build/ and /fonts/ folders are served as immutable. The site’s end-to-end tests check that /pagefind/pagefind-entry.json responds 200 and that searching for “install” returns docs results.

Check that the index was written

If the indexer fails, astro-pagefind logs an error and the build still finishes. After a build, look for these log lines, and for dist/pagefind/pagefind-entry.json:

Pagefind indexed <N> pages
Pagefind wrote index to <path>

publier dev does not build the index. The dev server serves the dist/pagefind/ from your last build, and without one the dialog has nothing to search.

Why search and llms-full.txt list different page counts

On 2026-10-30 the Pagefind index of this site held 94 pages, and llms-full.txt held 104. The two outputs select pages by different rules:

AspectPagefind indexllms-full.txt
SourceBuilt HTML that carries data-pagefind-bodyBuilt HTML pages with a <title> and a rendered main or article
CoversPages from the docs collectionDocs, blog, changelog and your own .astro pages, unless filtered by llms.collections
SkipsPages without data-pagefind-body, noindex pages, data-pagefind-ignore regions, draftsError routes, noindex pages, meta-refresh redirects, titleless pages, drafts

The docs collection of this site holds 94 pages, the same as the index. The extra 10 in llms-full.txt match the pages that the docs layout does not cover: the home page, pricing, three use-case pages, the blog index, three blog posts and the changelog index. That is arithmetic from the source tree, not a list read from the build output. The /contact page was added after the 94-vs-104 comparison, so a count taken now is expected to be one higher for llms-full.txt but not for the index.

This difference is by design. A page can be in the assistant export and not in reader search. To find the real difference on your own site, compare the Pagefind indexed <N> pages log line with the page count in llms-full.txt, then check each extra page for data-pagefind-body.

Search scope by product

Search opens scoped to where the reader is. From a page inside a docs product, results come from that product plus pages that belong to no product. From any other page, results come from everything. A product whose path is / counts as no product.

publier.config.yaml
search:
versions: current # current | all
products: current # current | all

products: all searches every product from every page. Any other value fails the build with an error naming search.products.

The products are the entries under nav.<variant>.products, or the registry products described in Product registry. A product you list by hand can set an id; see Product ids.

The dialog

The search dialog shows up to two checkboxes above the results. Both reset each time the dialog opens.

CheckboxAppears when
Search all productsThe reader is on a product page and search.products is current.
Include archived versionsThe site has a version with status: frozen.

Pages in a frozen version stay out of search unless the reader ticks Include archived versions, whatever search.versions says. A preview version is not archived. With the box ticked, archived pages join the results for the product’s live versions. From an archived page with the box unticked, the version scope is dropped so the results are not empty.

Each result carries two chips, one with the product’s name and one with its version. A frozen version’s chip reads v1 · archived. Chips are not added to sub-results.

Filters and attributes

Each docs page carries the Pagefind filters product, version and archived (true or false). A page outside every product carries every product id, so it appears in each product’s results. The docs layout also sets data-publier-search-product, data-publier-search-version and data-publier-search-archived on <main>. A custom page with its own data-pagefind-body gets the same filters at build time.

Version labels are one namespace across products. With Search all products ticked, the version scope still applies by label.

What Publier does not provide

  • Per-section scoping. There is one index for the whole site. Scoping is by version and by product only; Publier sets no other Pagefind filters.
  • Blog and changelog search. Only pages that carry data-pagefind-body are searchable, and Publier’s blog and changelog routes do not set it.
  • Query analytics. Publier records no search terms. Searches run in the reader’s browser against static files.
  • Semantic or natural-language search. Results are Pagefind’s keyword matches. The AI features page lists semantic search as roadmap.
  • A different search backend. docsShell({ search }) accepts 'pagefind' or false.
  • Search for a site served under a subpath. See Deployment.