配置

Hugo 搜索模块可用的站点和页面参数列表。

站点参数

hugo.yaml

1params:
2  search:
3    stall_threshold: 200

hugo.toml

1[params]
2  [params.search]
3    stall_threshold = 200

hugo.json

1{
2   "params": {
3      "search": {
4         "stall_threshold": 200
5      }
6   }
7}

case_sensitive

Indicates whether comparisons should be case sensitive.

NameTypeDefaultRequired
case_sensitivebooleanfalse-

distance

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.

NameTypeDefaultRequired
distancenumber100-

expand_results_meta

When true, expand the results meta by default.

NameTypeDefaultRequired
expand_results_metabooleanfalse-

filter_taxonomies

Whether to enable the taxonomies filter.

NameTypeDefaultRequired
filter_taxonomiesbooleantrue-

filter_years

Whether to enable the years filter.

NameTypeDefaultRequired
filter_yearsbooleantrue-

ignore_location

When true, search will ignore location and distance, so it won't matter where in the string the pattern appears.

NameTypeDefaultRequired
ignore_locationbooleanfalse-

index_all_pages

When true, all pages except noindex pages will be indexed, include non-regular pages, such as home and taxonomy lists.

NameTypeDefaultRequired
index_all_pagesbooleantrue-

index_content

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.

NameTypeDefaultRequired
index_contentbooleanfalse-

lazy_loading

Lazy loading the indices.

NameTypeDefaultRequired
lazy_loadingbooleantrue-

location

Determines approximately where in the text is the pattern expected to be found.

NameTypeDefaultRequired
locationnumber0-

max_results

Denotes the max number of returned search results.

NameTypeDefaultRequired
max_resultsnumber100-

min_match_char_length

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).

NameTypeDefaultRequired
min_match_char_lengthnumber1-

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.

NameTypeDefaultRequired
modal_containerstringbody-

The search modal toggle selector.

NameTypeDefaultRequired
modal_toggle_selectorstring.search-modal-toggle-

paginate

How many results per page, at least 20, for making sure the load more event will be able to trigger.

NameTypeDefaultRequired
paginatenumber20-

shortcut_close

Shortcuts to close the search modal. Empty array means disabled. See key values for keyboard events.

NameTypeDefaultRequired
shortcut_closearray[Escape]-

Shortcuts to open the search modal. Leave it empty to disable.

NameTypeDefaultRequired
shortcut_searcharray[Control k]-

stall_threshold

How many milliseconds must elapse before considering the autocomplete experience stalled.

NameTypeDefaultRequired
stall_thresholdnumber300-

threshold

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.

NameTypeDefaultRequired
thresholdnumber0.6-

页面参数

AKA front matter.

noindex

When true, the page won't be indexed, that is, it won't appear on the search results.

NameTypeDefaultRequired
noindexbooleanfalse-