By default, qwik-docs sites include full-text search powered by Pagefind, a fast, low-bandwidth search tool for static sites. This is the same search engine Astro Starlight uses.
No configuration is required to enable search. Use the search bar in the site header, or press Ctrl/⌘ + K, to find content.
How indexing works
Unlike Astro Starlight, qwik-docs does not index the built HTML. It builds the Pagefind index from your Markdown and MDX source. The index runs in two places:
- In dev, the framework builds an in-memory index on the first request to
/pagefind/and serves it from there. It rebuilds when a content file changes, so search works without a production build. - At build, the Vite plugin writes the index into the output directory during
closeBundle.
Because indexing reads the source, JSX component tags, import and export lines, and JSX expression blocks are stripped before text is indexed. The page title and Markdown prose, headings, lists, and code blocks are indexed.
Hide content in search results
Exclude a page
To exclude a page from the search index, add pagefind: false to the page's frontmatter:
---
title: Content to hide from search
pagefind: false
---
The pagefind frontmatter field defaults to true.
Exclude part of a page
To drop a single section from the index while keeping the rest of the page searchable, add Pagefind's data-pagefind-ignore attribute to an element.
The framework honors the attribute during the source pass, ported from Astro Starlight's use of the same attribute.
Any element carrying data-pagefind-ignore, and its children, are removed before the text is indexed.
Wrap the content to hide in an element with the attribute:
## Indexed heading
This prose is indexed.
<div data-pagefind-ignore>
## Excluded heading
This section, including its heading, is skipped by search.
</div>
The blank lines around the <div> let Markdown inside it render as usual.
Use data-pagefind-ignore for boilerplate, changelog noise, or repeated callouts you do not want cluttering results, and use pagefind: false to exclude a whole page.
Alternative search providers
Pagefind is the default, but it is not the only option.
The built-in search UI is the Search component, ported from Starlight's Search.astro.
Replace it through the components override map to wire up a different provider, such as Algolia DocSearch or Typesense.
Point the Search name at your replacement .tsx:
import { defineConfig } from '@qwik-docs/framework';
export default defineConfig({
components: {
Search: './src/overrides/Search.tsx',
},
});
Swap Pagefind for another provider
The override replaces the search UI on every page. Your component owns the search button, the modal, and the query to whichever backend you choose.
When you no longer need the Pagefind index, disable it with pagefind: false so the framework skips building it.
The overridden Search still renders even when Pagefind is off — the same behavior as Astro Starlight — so your provider's UI stays in the header:
import { defineConfig } from '@qwik-docs/framework';
export default defineConfig({
pagefind: false,
components: {
Search: './src/overrides/DocSearch.tsx',
},
});
Load the provider's client script and styles from inside your component, and read the current page data with useRouteData if you need it.
See Overriding Components for how the override map resolves your file, and the Overrides Reference for the full list of overridable component names.