Search Module
The search module adds a full-text search page at /search, powered by Pagefind. Search is entirely static — no server required.
Adding the search module
In karaoke.config.ts:
import { defineConfig } from '@karaoke-cms/astro';
import { search } from '@karaoke-cms/module-search';
import { themeDefault } from '@karaoke-cms/theme-default';
export default defineConfig({
vault: env.KARAOKE_VAULT,
title: 'My Site',
theme: themeDefault(),
modules: [
search(),
],
});
Options
| Option | Default | Description |
|---|---|---|
mount | /search | URL for the search page |
enabled | true | Set false to exclude from the build |
search({
mount: '/search',
enabled: true,
})
Routes injected
| Route | Description |
|---|---|
/search | Full-text search page |
Building the search index
Pagefind generates its search index by crawling the production build output. The index does not exist until you run a build.
npm run build
# or
pnpm build
After the build completes, the index is saved to dist/pagefind/. The dev server automatically serves this directory, so search works in dev mode after the first build.
If you have never run a build, the search page will have no results in dev mode. Run npm run build once, then start the dev server — search will work from that point on.
What gets indexed
Only published pages are indexed. Pages with publish: false or no publish field in frontmatter are excluded from the search index, the same as they are excluded from the rest of the site.
Rebuilding the index
Run npm run build again any time you want to update the search index with new or changed content. The dev server picks up the new dist/pagefind/ automatically — no restart needed.