Mukha has integrated indexing and search using lunr.
Search works independently of the content delivery method.
Integrated support for languages from the lunr-languages package.
For search to work, the Java Script API must be enabled (instructions). Further steps:
Several options are responsible for search settings. First - enabling search:
search: true
The next option is responsible for saving article excerpts. If set to true, search results will include not only titles but also excerpts:
keep_excerpts: true
Indexing and search languages. If all your text is only in English, you can leave this unset. If another language is used - or several, they must be listed:
search_lang: ["ru", "en"]
Note - the value of this option is always a list. If you want to specify one language, do it like this:
search_lang: ["de"]
If you only use English, Chinese, and Russian languages - this step is not needed. For other languages, you need to install language files on the site so the search client can load them.
Language files should be located at /_js/lib/lunr/lang, in files named lunr.<language code>.js.
For example, the file for the Armenian language is called lunr.hy.js.
It's convenient to create the corresponding directory in the assets folder within the site folder. The files themselves
can be taken from the Lunr-languages repository or
installed from npm.
These files are only needed for the client to work; indexing in all supported languages does not require additional files.
The search itself is provided by the search_client.js script, which is included in the Mukha
distribution. If you installed Mukha from npm, it is located in the same directory as
the main script. The easiest way is to place it in the assets folder, and it will end up in the site root.
Next, you need to include it in the template - somewwhere after the JS API - best
before the closing </body> tag:
<script src="/search_client.js"></script>
If you want to use the standard search UI, you need to place a text input field
somewhere at the top of the page and add the attribute data-role:lunr-search to it.
<input type="text" data-role="lunr-search" placeholder="Search">
If you add the disabled attribute to this input field, this attribute will be removed after the search files are loaded.
This can be used to signal to the user that the search is ready.
After generation, you may enter words into this form, and search results will be displayed in a dropdown menu below it.
You can create your own UI for search; instructions will be provided.