Skip to content

Site Search

Learn about Starlight’s built-in site search features and how to customize them.

By default, Starlight sites include full-text search powered by Pagefind, which is a fast and low-bandwidth search tool for static sites.

No configuration is required to enable search. Build and deploy your site, then use the search bar in the site header to find content.

To exclude a page from your search index, add pagefind: false to the page’s frontmatter:

src/content/docs/not-indexed.md
---
title: Content to hide from search
pagefind: false
---

Pagefind will ignore content inside an element with the data-pagefind-ignore attribute.

In the following example, the first paragraph will display in search results, but the contents of the <div> will not:

src/content/docs/partially-indexed.md
---
title: Partially indexed page
---
This text will be discoverable via search.
<div data-pagefind-ignore>
This text will be hidden from search.
</div>

If you have access to Algolia’s DocSearch program and want to use it instead of Pagefind, you can use the official Starlight DocSearch plugin.

With this updated configuration, the search bar on your site will now open an Algolia modal instead of the default search modal.

The Starlight DocSearch plugin supports customizing the DocSearch component with the following inline options:

  • maxResultsPerGroup: Limit the number of results displayed for each search group. Default is 5.
  • disableUserPersonalization: Prevent DocSearch from saving a user’s recent searches and favorites to local storage. Default is false.
  • insights: Enable the Algolia Insights plugin and send search events to your DocSearch index. Default is false.
  • searchParameters: An object customizing the Algolia Search Parameters.

A separate configuration file is required to pass function options like transformItems() or resultsFooterComponent() to the DocSearch component.

See the DocSearch JavaScript client API Reference for all supported options.

DocSearch only provides English UI strings by default. Add translations of the modal UI for your language using Starlight’s built-in internationalization system.

Community plugins can also provide alternatives to Starlight’s built-in Pagefind search provider.

The Starlight DocSearch Typesense community plugin provides an open-source and self-hostable alternative that integrates the DocSearch interface with a Typesense backend.

See the “Getting Started” guide in the Starlight DocSearch Typesense documentation to learn how to use it in your project.