Search: Lunr.js
Table of Contents
Configure Lunr.js Search Client
Select Lunr.js as the search client in your config.toml file:
[params.search]
client = "lunr"Generate Search Index for Lunr.js
Lunr.js will need a search index for searching across your site. So, you’ll need to generate that search index for Lunr.js before you deploy your site.
Engimo comes with a script for generating the search index for Lunr.js: /scripts/generate-search-index-lunr.js.
Install Dependencies
Node.js must be installed on your system for using the generator script.
It also need the following npm packages:
globlunr
For installing lunr and glob globally use the following command:
npm install -g lunr globRun the Script
After you’ve generated your site with Hugo, run generate-search-index-lunr.js with node.
If Engimo is installed under /themes/engimo directory, you’ll run it as:
node ./themes/engimo/scripts/generate-search-index-lunr.jsThe generate-search-index-lunr.js script accepts an optional argument for Hugo’s publishDir (relative to your site’s root directory).
So, if you’ve got a different publishDir (say site), pass it as the first argument:
node ./themes/engimo/scripts/generate-search-index-lunr.js siteIf the generation was successful, you’ll see output like this:
Lunr.js Index Generated for: /search/index.jsonThat’s all. Now you can deploy your site.