Default Theme: Search
Configure search functionality for your VitePress site.
Local Search
VitePress supports fuzzy full-text search using a client-side index built from page content.
js
import { defineConfig } from 'vitepress'
export default defineConfig({
themeConfig: {
search: {
provider: 'local'
}
}
})
Search Options
Exclude Pages
You can exclude pages from search results:
js
export default defineConfig({
themeConfig: {
search: {
provider: 'local',
options: {
exclude: ['guide/api.md', 'reference/cli.md']
}
}
}
})
Custom Search Root
Specify a custom search root:
js
export default defineConfig({
themeConfig: {
search: {
provider: 'local',
options: {
searchRoot: 'docs'
}
}
}
})
Algolia Search
For larger sites, you can use Algolia DocSearch:
js
export default defineConfig({
themeConfig: {
search: {
provider: 'algolia',
options: {
appId: 'YOUR_APP_ID',
apiKey: 'YOUR_SEARCH_API_KEY',
indexName: 'YOUR_INDEX_NAME'
}
}
}
})
Search Translations
Customize search interface text:
js
export default defineConfig({
themeConfig: {
search: {
provider: 'local',
options: {
translations: {
button: {
buttonText: 'Search',
buttonAriaLabel: 'Search'
},
modal: {
noResultsText: 'No results for',
resetButtonTitle: 'Clear search',
footer: {
selectText: 'to select',
navigateText: 'to navigate',
closeText: 'to close'
}
}
}
}
}
}
})
Frontmatter Search Control
Control search indexing per page:
yaml
---
search: false
---
Or provide custom search terms:
yaml
---
searchTerms: ['custom', 'search', 'keywords']
---