Skip to content

Latest commit

 

History

History
56 lines (43 loc) · 1.29 KB

README.md

File metadata and controls

56 lines (43 loc) · 1.29 KB

lunr-hugo

Generate lunr.js index files from Hugo static sites

A simple way to add site search to your static Hugo site using Lunr.js.

Installation

Install the lunr-hugo utility via npm:

$ npm install lunr-hugo

Options

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.

How to use lunr-hugo CLI

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

How to use lunr-hugo API

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();

License

This project is a fork from https://github.com/dgrigg/hugo-lunr It is under ISC License. Check LICENSE.md for more information.