Install the Plugin
Setting up the smart search plugin for your Docusaurus documentation requires careful preparation and attention to detail. By following these instructions, you'll be able to enhance your documentation with powerful search capabilities that improve user experience and content discoverability.
Prerequisites
Before installing the Smart Search Plugin, ensure you have:
- A Docusaurus 2.x project set up
- Node.js and npm/yarn installed
- Proper directory structure in your Docusaurus project:
your-docusaurus-site/
├── docs/ # Documentation root
│ ├── intro.md # Documentation files
│ └── advanced/
│ └── config.md
├── static/ # Static assets directory and the searchIndex.json
└── docusaurus.config.js # Configuration file - Required document metadata structure:
---
title: Document Title
description: A brief description that appears in search results
keywords: [search, docusaurus, plugin]
draft: false # if set to `true`, the topic is excluded from the search index
last_update:
date: 12/11/2024
# other metadata fields
---
Install and configure the plugin
Install the plugin using npm or yarn:
npm install smart-search-plugin
yarn add smart-search-plugin
Configure your
docusaurus.config.js
:const path = require('path');
module.exports = {
staticDirectories: ['static'],
plugins: [
path.resolve(__dirname, 'node_modules/smart-search-plugin')
],
presets: [
['@docusaurus/preset-classic',
{
docs: {
routeBasePath: '/',
path: 'docs',
showLastUpdateTime: true,
},
},
],
],
themeConfig: {
navbar: {
items: [
{
type: 'search',
position: 'right',
},
],
},
},
};
Verifying your installation
After installation:
Start your development server:
npm start
yarn start
Check that the search icon appears in your navigation bar.
Try performing a basic search.