Skip to content

Repository files navigation

docusaurus-plugin-pagefind

npm version npm downloads CI License: MIT

A Docusaurus plugin that integrates Pagefind as a fast, offline-capable full-text search solution, using the DocSearch UI shell.

🔗 Live Demo

demo

Features

  • Full-text search powered by Pagefind (build-time indexing, no server required)
  • DocSearch-style UI: keyboard shortcut (Ctrl+K / Cmd+K), modal, hit highlighting
  • Light and dark theme support out of the box
  • Exclude pages from the search index via CSS selectors or glob patterns
  • TypeScript support and swizzleable SearchBar component

Requirements

  • Docusaurus ≥ 3.0
  • Node.js 22.x
  • pagefind ≥ 1.0

Installation

pnpm add docusaurus-plugin-pagefind
pnpm add -D pagefind

Usage

// docusaurus.config.ts
export default {
  plugins: [
    [
      'docusaurus-plugin-pagefind',
      {
        forceLanguage: 'ja',          // optional: force pagefind language
        excludeGlobs: ['**/hidden/**'], // optional: exclude pages from index
      },
    ],
  ],
}

Options

Option Type Default Description
forceLanguage string Language code passed to pagefind
excludeSelectors string[] .navbar, footer, ... Extra CSS selectors excluded from index (added on top of the built-in exclusions)
rootSelector string Root element for indexing
excludeGlobs string[] Pages to exclude (glob relative to outDir)

Swizzling

pnpm docusaurus swizzle docusaurus-plugin-pagefind SearchBar

The SearchBar component depends on @docsearch/react and @docsearch/css, which ship as dependencies of this plugin — no extra install is needed for the default (non-swizzled) search bar.

If you eject the component (--eject), the copied source lives in your site's src/theme. Most setups resolve the imports transparently, but strict installers that don't hoist (e.g. pnpm without shamefully-hoist) may not reach the plugin's copy from your site. In that case, install them directly:

pnpm add @docsearch/react @docsearch/css

Community

License

MIT

About

A Docusaurus plugin that integrates Pagefind

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages