Pagefind Search Indexer
Guidelines for indexing static websites and configuring search capabilities using Pagefind. Always consult the local Pagefind Docs and Pagefind Config Options for full options reference.
CLI & Core Indexing Commands
Run Pagefind post-build to index the output HTML content:
- Default Indexing:
npx pagefind --site <build_output_dir>(indexes all HTML pages in the output directory, e.g.,dashboard/public). - Config file: Pagefind can load parameters from a
pagefind.ymlorpagefind.jsonfile placed in the project root.
Client Integration Rules
- JS/CSS Assets: Pagefind generates static search assets (compiled index and search UI scripts) under the
pagefinddirectory in the site root (e.g.pagefind/pagefind.js,pagefind/pagefind.css). - Excluding Elements: To keep irrelevant layout elements (such as footers, navbars, sidebars) from polluting search index scores, add
data-pagefind-ignoreattribute to their HTML elements. - Weighting Content: To highlight specific regions (e.g., titles, primary paragraphs), use
data-pagefind-weight="<value>"(value from 1 to 10) on elements.
Completion Criteria
The indexing task is complete when:
pagefindcompletes building the search database successfully without throwing errors.- The index folder
pagefind/exists in the public output directory containing the generated search chunks and compiled index configs. - Relevant search query tests return expected matches.