Skip t' th' main rrreadin'

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 yer project configurat'n:

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

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

    [params.search.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:
  search:
    index:
      URL: omnisearchindex.js
    plank:
      URL: omnisearch
[params]
  [params.search]
    [params.search.index]
      URL = 'omnisearchindex.js'

    [params.search.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 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.

hugo.
params:
  search:
    adapter:
      identifier: lunr
[params]
  [params.search]
    [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. 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.

hugo.
params:
  search:
    adapter:
      params:
        additionalContentLanguage:
        - en
[params]
  [params.search]
    [params.search.adapter]
      [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:
  search:
    index:
      template: /custom_searchindex.js
[params]
  [params.search]
    [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 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:

hugo.
params:
  search:
    plank:
      type: custom_search_layout
[params]
  [params.search]
    [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 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:

hugo.
params:
  search:
    plank:
      outputs:
      - html
[params]
  [params.search]
    [params.search.plank]
      outputs = ['html']
{
   "params": {
      "search": {
         "page": {
            "outputs": [
               "html"
            ]
         }
      }
   }
}

T' always offer it:

hugo.
params:
  search:
    plank:
      outputs:
      - html
      - print
[params]
  [params.search]
    [params.search.plank]
      outputs = ['html', 'print']
{
   "params": {
      "search": {
         "page": {
            "outputs": [
               "html",
               "print"
            ]
         }
      }
   }
}
Avast

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