
The search module integrates HB with the Hugo Search Module, a powerful, flexible and responsive Hugo client side fuzzy search module.
This module can not be imported directly, you’ll need a entry point, such as the search button generated by header’s search module. You can also write your own widget with this module.
| Module Path | Version |
|---|---|
github.com/razonyang/hb/modules/search |
| Name | Type | Default | Description |
|---|---|---|---|
stall_threshold | Integer | 300 | How many milliseconds must elapse before considering the autocomplete experience stalled. |
case_sensitive | Boolean | false | Indicates whether comparisons should be case sensitive. |
min_match_char_length | Integer | 1 | Only the matches whose length exceeds this value will be returned. (For instance, if you want to ignore single character matches in the result, set it to 2). |
location | Integer | 0 | Determines approximately where in the text is the pattern expected to be found. |
threshold | Integer | 0.6 | At what point does the match algorithm give up. A threshold of 0.0 requires a perfect match (of both letters and location), a threshold of 1.0 would match anything. |
distance | Integer | 100 | Determines how close the match must be to the fuzzy location (specified by location). An exact letter match which is distance characters away from the fuzzy location would score as a complete mismatch. A distance of 0 requires the match be at the exact location specified. A distance of 1000 would require a perfect match to be within 800 characters of the location to be found using a threshold of 0.8. |
ignore_location | Boolean | false | When true, search will ignore location and distance, so it won’t matter where in the string the pattern appears. |
shortcut_close | Array | ["Escape"] | Shortcuts to close the search modal. Empty array means disabled. See key values for keyboard events. |
shortcut_search | Array | ["Control", "k"] | Shortcuts to open the search modal. Leave it empty to disable. |
paginate | Integer | 20 | How many results per page, at least 20, for making sure the load more event will be able to trigger. |
max_results | Integer | 100 | Denotes the max number of returned search results. |
index_content | Boolean | false | When true, the engine will also search by content, you may need to tweak the distance parameter as well. Please note that, it may become a performance killer on a large site. |
index_all_pages | Boolean | true | When true, all pages except noindex pages will be indexed, include non-regular pages, such as home and taxonomy lists. |
expand_results_meta | Boolean | false | When true, expand the results meta by default. |
modal_container | String | body | The container for the search modal. It should be a valid CSS selector. Leave it empty if you’re using single search page mode only. |
lazy_loading | Boolean | true | Lazy loading the indices. |
params.toml
1[search]
2 min_match_char_length = 3
params.yaml
1search:
2 min_match_char_length: 3
params.json
1{
2 "search": {
3 "min_match_char_length": 3
4 }
5}
See Hugo Search Module for details.