Search
Th' search term will be stored 'n th' reader’s browser as long as it be present.
Configure Search
Th' theme offers three levels o' search through th' menu’s search form:
- In-page search: Highlights search terms on th' current plank
- Search popup: Opens a popup wit' results from other planks
- Dedicated search plank: Access'ble by click'n th' magnifier glass or press'n ENTER
Each level requires th' previous one t' be enabled. If no search be configured, th' search form won’t appear.
Opt'n All levels be enabled by default. Dis'ble them 'n yer project configurat'n:
- In-page search: set
search.dis'blet'true - Search popup: set
search.index.dis'blet'true - Dedicated search plank: set
search.page.dis'blet'true
Search URLs
Opt'n Default URLs can be changed wit' th' follow'n parameter
- Search popup:
searchindex.jsset bysearch.index.URL - Dedicated search plank:
search/index.htmlset bysearch.page.URL
Ye only need t' change these if ye have own rrrambl'n created fer those URLs. This can happen wit' uglyURLs set t' true 'n yer project configurat'n an' hav'n a rrrambl'n file at content/search.md.
Check fer duplicate URLs by runn'n hugo --printPathWarn'ns.
Search Adapter / Engine
Opt'n Th' theme supports different search engines through adapters. Each different adapter may have its own set o' configurat'n.
By default, it uses th' Lunr search engine.
Lunr
lunr be th' default search adapter.
Supported Languages
Lunr doesn’t support all languages o' th' theme. Rrrambl'n o' an unsupported language be dropped from th' search index, so search'n it will not return any results. Th' theme warns ye about this dur'n yer Cap'n Hugo build. Currently unsupported be
- Czech
- Indonesian
- Persian
- Swahili
- Ukrainian
Mixed Language Support
Opt'n In case yer page’s rrrambl'n contains text 'n multiple languages (for example, ye be writ'n a Piratish documentat'n fer yer English API), ye can set those languages 'n search.adapter.params.additionalContentLanguage t' broaden th' search.
Ye can add multiple languages t' this array.
Use th' base language code. For example, if yer plank be us'n zh-CN, add zh t' this parameter.
Experimental Adapters
Th' theme also ships wit' th' additional experimental orama an' orama-esm (not us'ble fer headless server deployments) adapters.
Customiz'n th' Search Index Generat'n
Opt'n Ye can cust'mize how th' search index be generated by specify'n a different template:
By default, th' theme uses /_relearn_searchindex.js t' generate th' search index. When ye specify a custom value fer search.index.template, th' theme will look fer th' template file 'n yer site’s assets directory.
For example, if ye set search.index.template t' /custom_searchindex.js, ye would need t' create a file at assets/custom_searchindex.js 'n yer ship t' define th' custom index generat'n logic.
This advanced option be useful if ye need t' modify how rrrambl'n be indexed or change th' structure o' th' search index t' work wit' custom search implementat'ns.
Customiz'n th' Search Plank Layout
Opt'n Ye can cust'mize th' appearance o' th' dedicated search plank by chang'n its rrrambl'n view:
By default, th' theme uses _relearn_searchpage as th' search rrrambl'n view. When ye set search.page.type t' a custom value [YOUR-VIEWNAME], Cap'n Hugo will look fer a template file at layouts/[YOUR-VIEWNAME]/article.html.
For example, if ye set search.page.type t' custom_search_layout, ye would need t' create a file at layouts/custom_search_layout/article.html 'n yer ship t' define th' custom layout.
This allows ye t' maintain th' search functionality while adapt'n its appearance t' match yer specific design requirements.
Print'n th' Search Results
If yer home plank has print support activated, yer readers can print their search results as well. Th' search plank then shows th' print button, an' th' printed plank lists th' results fer th' current search term without th' search form.
Opt'n Th' dedicated search plank be not part o' yer rrrambl'n, so th' outputs o' yer project configurat'n or o' a front matter don’t apply t' it. If ye want t' decide independently o' yer home plank, set its output formats wit' search.page.outputs.
T' never offer print'n th' search results:
T' always offer it:
As long as th' option be not set, th' print version o' th' search plank be always written t' yer ship, as th' theme can not tell at that point whether yer home plank can be printed. It be just not offered t' yer readers if it can’t.
Migrat'n from Relearrrn 7
In previous versions o' th' theme, search configurat'n used flat parameters. Th' current version uses a more structured approach wit' a search namespace.
If you’re updat'n from an older version, here’s how t' migrate yer search configurat'n:
Migrat'n T'ble
| Legacy Parameter | New Parameter |
|---|---|
disableSearch |
search.dis'ble |
disableSearchIndex |
search.index.dis'ble |
disableSearchPage |
search.page.dis'ble |
searchIndexURL |
search.index.URL |
searchPageURL |
search.page.URL |
additionalContentLanguage |
search.adapter.params.additionalContentLanguage |