hugo-theme-relearn/exampleSite/content/configuration/sidebar/search/_index.en.md

71 lines
2.5 KiB
Markdown
Raw Normal View History

2024-09-29 21:48:56 +00:00
+++
description = "Configure search and the search form"
options = ["additionalContentLanguage", "disableSearch", "disableSearchIndex", "disableSearchPage", "searchIndexURL", "searchPageURL"]
2024-09-29 21:48:56 +00:00
title = "Search"
weight = 3
+++
## Configure Search
2024-10-07 13:30:53 +00:00
The theme offers three levels of search through the menu's search form:
2024-09-29 21:48:56 +00:00
2024-10-07 13:30:53 +00:00
1. In-page search: Highlights search terms on the current page
2. Search popup: Opens a popup with results from other pages
3. Dedicated search page: Accessible by clicking the magnifier glass or pressing <kbd>ENTER</kbd>
2024-09-29 21:48:56 +00:00
2024-10-07 13:30:53 +00:00
Each level requires the previous one to be enabled. If no search is configured, the search form won't appear.
2024-09-29 21:48:56 +00:00
2024-10-07 13:30:53 +00:00
{{%badge style="cyan" icon="gears" title=" "%}}Option{{%/badge%}} All levels are enabled by default. Disable them in `hugo.toml`:
2024-09-29 21:48:56 +00:00
2024-10-07 13:30:53 +00:00
- In-page search: `disableSearch=true`
- Search popup: `disableSearchIndex=true`
- Dedicated search page: `disableSearchPage=true`
2024-09-29 21:48:56 +00:00
2024-10-07 13:30:53 +00:00
{{< multiconfig file=hugo >}}
[params]
disableSearch = true
disableSearchIndex = true
disableSearchPage = true
{{< /multiconfig >}}
{{%badge style="cyan" icon="gears" title=" "%}}Option{{%/badge%}} Default URLs can be changed with the following parameter
- Search popup: `searchindex.js` set by `searchIndexURL`
- Dedicated search page: `search/index.html` set by `searchPageURL`
2024-09-29 21:48:56 +00:00
2024-10-07 13:30:53 +00:00
{{< multiconfig file=hugo >}}
[params]
searchIndexURL = 'mysearchindex.js'
searchPageURL = 'megasearch'
{{< /multiconfig >}}
2024-09-29 21:48:56 +00:00
{{% notice note %}}
2024-10-07 13:30:53 +00:00
Only change these if you have content at those URLs. This can happen with `uglyURLs=true` in `hugo.toml` and having a content file at `content/search.md`.
2024-09-29 21:48:56 +00:00
2024-10-07 13:30:53 +00:00
Check for duplicate URLs by running `hugo --printPathWarnings`.
2024-09-29 21:48:56 +00:00
{{% /notice %}}
## Supported Languages
2024-10-07 13:30:53 +00:00
The [Lunr](https://lunrjs.com) search library doesn't support all languages of the theme. Unsupported languages will show errors in the browser console. Currently unsupported are
2024-09-29 21:48:56 +00:00
- Czech
- Indonesian
- Polish
- Swahili
2024-10-07 13:30:53 +00:00
## Mixed Language Support
2024-09-29 21:48:56 +00:00
2024-10-07 13:30:53 +00:00
{{%badge style="cyan" icon="gears" title=" "%}}Option{{%/badge%}} In case your page's content contains text in multiple languages (for example, you are writing a Piratish documentation for your English API), you can set those languages in `additionalContentLanguage` to broaden the search.
2024-09-29 21:48:56 +00:00
{{< multiconfig file=hugo >}}
[params]
additionalContentLanguage = [ "en" ]
{{< /multiconfig >}}
2024-10-07 13:30:53 +00:00
You can add multiple languages to this array.
2024-09-29 21:48:56 +00:00
{{% notice note %}}
2024-10-07 13:30:53 +00:00
Use the base language code. For example, if your page is using `zh-CN`, add `zh` to this parameter.
2024-09-29 21:48:56 +00:00
{{% /notice %}}