A simple way to add site search to your static Hugo site using Lunr.js.
Install the lunr-hugo utility via npm:
$ npm install lunr-hugo
By default lunr-hugo will read the content
directory of you and output the lunr index to public/lunr.json
. If you are using the command line implementation you can pass an input directory -i
and and output path/file -o
.
The easiest way to use lunr-hugo is via npm scripts:
"scripts": {
"index": "lunr-hugo"
},
or to pass arguments for input and output:
"scripts": {
"index": "lunr-hugo -i \"content/subdir/**\" -o public/my-index.json"
},
Which can be executed from a terminal prompt
$ npm run index
var hugolunr = require('lunr-hugo');
new hugolunr().index();
or to set input/output paths
var hugolunr = require('lunr-hugo');
var h = new hugolunr();
h.setInput('content/faq/**');
h.setOutput('public/faq.json');
h.index();
This project is a fork from https://github.com/dgrigg/hugo-lunr It is under ISC License. Check LICENSE.md for more information.