Skip to content
Tartarus

Search

How Pagefind indexing works and how to control what is searchable.

On this page

Search is static. There is no service to sign up for, no index to keep in sync and no request that leaves the reader's browser except for the index files themselves.

The pipeline

text
Markdown  →  Hugo  →  static HTML  →  Pagefind index  →  search UI

Pagefind runs after Hugo, crawls public/, and writes a fragmented index into public/pagefind/. The browser downloads only the fragments a query touches, so the cost of search does not grow with the size of your documentation.

What gets indexed

Only the element marked data-pagefind-body — the page heading, description and body content. Navigation, breadcrumb, table of contents and the previous/next links are outside it, so they never pollute results.

To exclude part of a page, mark it in your Markdown:

html
<div data-pagefind-ignore>
  This block is rendered but never indexed.
</div>

To exclude a whole page, add it to the front matter of that page:

yaml
---
title: Internal notes
build:
  list: never
---

The palette

KeyAction
K / CtrlKOpen search
/Open search when not typing
Move between results
EnterOpen the selected result
EscClose

The dialog is a native <dialog> element, so focus trapping, the inert background and Esc come from the browser rather than from JavaScript.

Configuration

toml
[params.search]
  enable = true
  placeholder = "Search documentation..."
  maxResults = 12
Note

Under pnpm dev the index does not exist yet and the palette says so. Run pnpm preview to build the index and browse the production output locally.

Searching…

No results for “

Type to search the documentation.