Search

Avast

Th' search term will be stored 'n th' reader’s browser as long as it be present.

Th' theme offers three levels o' search through th' menu’s search form:

  1. In-page search: Highlights search terms on th' current plank
  2. Search popup: Opens a popup wit' results from other planks
  3. 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 hugo.toml:

  • In-page search: search.disable=true
  • Search popup: search.index.disable=true
  • Dedicated search plank: search.page.disable=true
hugo.
[params]
  [params.search]
    dis'ble = true

    [params.search.index]
      dis'ble = true

    [params.search.plank]
      dis'ble = true
params:
  search:
    dis'ble: true
    index:
      dis'ble: true
    plank:
      dis'ble: true
{
   "params": {
      "search": {
         "disable": true,
         "index": {
            "disable": true
         },
         "page": {
            "disable": true
         }
      }
   }
}

Search URLs

Opt'n Default URLs can be changed wit' th' follow'n parameter

  • Search popup: searchindex.js set by search.index.URL
  • Dedicated search plank: search/index.html set by search.page.URL
hugo.
[params]
  [params.search]
    [params.search.index]
      URL = 'omnisearchindex.js'

    [params.search.plank]
      URL = 'omnisearch'
params:
  search:
    index:
      URL: omnisearchindex.js
    plank:
      URL: omnisearch
{
   "params": {
      "search": {
         "index": {
            "URL": "omnisearchindex.js"
         },
         "page": {
            "URL": "omnisearch"
         }
      }
   }
}
Avast

Ye only need t' change these if ye have own rrrambl'n created fer those URLs. This can happen wit' uglyURLs=true 'n hugo.toml 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 has its own set o' configurat'n.

By default, it uses th' Lunr search engine.

hugo.
[params]
  [params.search]
    [params.search.adapter]
      identifier = 'lunr'
params:
  search:
    adapter:
      identifier: lunr
{
   "params": {
      "search": {
         "adapter": {
            "identifier": "lunr"
         }
      }
   }
}

Lunr

lunr be th' default search adapter.

Supported Languages

Lunr doesn’t support all languages o' th' theme. Unsupported languages will show errors 'n th' browser console. Currently unsupported be

  • Czech
  • Indonesian
  • Persian
  • Polish
  • 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.

hugo.
[params]
  [params.search]
    [params.search.adapter]
      [params.search.adapter.params]
        additionalContentLanguage = ['en']
params:
  search:
    adapter:
      params:
        additionalContentLanguage:
        - en
{
   "params": {
      "search": {
         "adapter": {
            "params": {
               "additionalContentLanguage": [
                  "en"
               ]
            }
         }
      }
   }
}

Ye can add multiple languages t' this array.

Avast

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:

hugo.
[params]
  [params.search]
    [params.search.index]
      template = '/custom_searchindex.js'
params:
  search:
    index:
      template: /custom_searchindex.js
{
   "params": {
      "search": {
         "index": {
            "template": "/custom_searchindex.js"
         }
      }
   }
}

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 = '/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 opt'n 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:

hugo.
[params]
  [params.search]
    [params.search.plank]
      type = 'custom_search_layout'
params:
  search:
    plank:
      type: custom_search_layout
{
   "params": {
      "search": {
         "page": {
            "type": "custom_search_layout"
         }
      }
   }
}

By default, th' theme uses _relearn_searchpage as th' search rrrambl'n view. When ye specify a custom value fer search.page.type=[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 = '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.

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