Documentation Index
Fetch the complete documentation index at: https://mintlify.com/facebook/docusaurus/llms.txt
Use this file to discover all available pages before exploring further.
@docusaurus/theme-search-algolia integrates Algolia DocSearch into your Docusaurus site. Once installed and configured, it replaces the empty SearchBar slot in the navbar with a fully functional search modal, and adds a dedicated search results page at /search with OpenSearch support. The theme is included automatically when you use @docusaurus/preset-classic, so most users only need to supply their Algolia credentials.
Installation
If you are using
@docusaurus/preset-classic, theme-search-algolia is already installed. Skip to Configuration.docusaurus.config.js
Getting Algolia DocSearch credentials
Algolia DocSearch offers a free hosted crawling service for open-source documentation sites. To get credentials:Apply to DocSearch
Submit your site at docsearch.algolia.com/apply. The Algolia team reviews applications and provisions a free crawler for qualifying open-source sites.
Accept the invitation
Once approved, you receive an email invitation to the Algolia application. Accept it to gain access to the Algolia dashboard.
Retrieve your credentials
In the Algolia dashboard, navigate to your application. You need three values:
- Application ID (
appId) - Search-only API key (
apiKey) — this is a public key, safe to commit - Index name (
indexName)
Add credentials to docusaurus.config.js
Place all three values in
themeConfig.algolia. See the Configuration section below.Configuration
All Algolia options are set insidethemeConfig.algolia in docusaurus.config.js.
Required fields
| Option | Type | Description |
|---|---|---|
appId | string | Your Algolia Application ID. |
apiKey | string | Your public search-only API key. |
indexName | string | The Algolia index to query. |
Optional fields
| Option | Type | Default | Description |
|---|---|---|---|
contextualSearch | boolean | true | When true, filters search results to match the current docs version and locale automatically, using Algolia facet filters. Strongly recommended for versioned or i18n sites. |
searchParameters | object | {} | Additional parameters passed directly to the Algolia search API (e.g., facetFilters, hitsPerPage). See the Algolia Search API docs for available options. |
searchPagePath | string | false | 'search' | The path for the dedicated search results page. Set to false to disable the search page entirely. |
externalUrlRegex | string | undefined | A regex string. Matching search result URLs are opened in a new browser tab instead of the current one. Useful for multi-site Algolia indexes. |
replaceSearchResultPathname | object | undefined | Replaces a portion of the URL in search results. Useful when the indexed URL differs from the served URL (e.g., different base paths). |
insights | boolean | false | Enables the Algolia Insights plugin to track search analytics events. |
Complete example
docusaurus.config.js
Contextual search
Contextual search is the most important option for sites with multiple documentation versions or multiple locales. When enabled, the search widget automatically injects facet filters that restrict results to the current version and current locale — so a user browsing thev2 docs won’t see results from v3 or from a different language.
docusaurus.config.js
Customizing the search UI
Custom search page path
By default, the full search results page is available at/search. Change the path or disable it entirely:
docusaurus.config.js
Custom search bar position
By default, the search bar appears at the far right of the navbar. You can reposition it using thesearch navbar item type:
docusaurus.config.js
Swizzling search components
You can customize the search UI by swizzling the components provided by this theme:CSS customization
The search bar and modal use CSS custom properties that you can override in yourcustom.css:
src/css/custom.css
Troubleshooting indexing
Search returns no results
Search returns no results
Verify that the
appId, apiKey, and indexName in your config exactly match the values in the Algolia dashboard — they are case-sensitive. Then check whether the index contains any records by browsing to it in the Algolia dashboard under Indices.If you recently deployed your site, the DocSearch crawler may not have run yet. Manually trigger a crawl in the Algolia Crawler dashboard.Wrong version results appear
Wrong version results appear
Enable
contextualSearch: true to filter results by version automatically. Also verify that your Algolia index includes docusaurus_tag as a facet attribute in the index configuration.Results point to incorrect URLs
Results point to incorrect URLs
If your site is deployed at a subpath (e.g.,
/docs/) but the index was crawled at the root, use replaceSearchResultPathname to rewrite the URLs:docusaurus.config.js
Local development shows no search results
Local development shows no search results
The DocSearch crawler indexes your live, publicly accessible site. During local development the crawler has not indexed
localhost, so search returns no results. This is expected behavior. Deploy your site and wait for a crawl to populate the index.Alternatively, use the Algolia DocSearch Scraper locally to index a local build.Search does not work with i18n
Search does not work with i18n
Make sure
contextualSearch is true and that your Algolia index includes language as a facet. When DocSearch crawls a multi-locale site, each page should receive the correct language attribute based on the URL path or locale prefix.OpenSearch support
The search page at/search automatically includes an OpenSearch description file. This allows browsers and toolbars that support OpenSearch to offer your site as a built-in search engine. No extra configuration is required.