Sidebar
-
Width
Changing the width of the sidebar
-
Header & Footer
Configure the header and footer
-
Search
Configure search and the search form
-
Menus
Configure all things menus
Relearn
Changing the width of the sidebar
Configure the header and footer
Configure search and the search form
Configure all things menus
The theme adjusts the menu width based on browser size.
If you want to change the chosen default width, you can add CSS variables to layouts/partials/custom-header.html.
The menu width changes for different screen sizes:
| Screen Size | Screen Width | Menu Width |
|---|---|---|
| Small | < 48rem | 14.375rem |
| Medium | 48rem - 60rem | 14.375rem |
| Large | >= 60rem | 18.75rem |
You can change the menu width but not the screen width breakpoints.
To adjust the menu width, use these CSS variables. Note that --MENU-S-width is for the mobile menu flyout on small screens.
See the title & logo configuration on how to set a title and a logo.
By default, the theme displays a home button between search form and navigation menu. The Home button serves as an alternative to clicking the logo.
Option To hide the Home button on the left menu, set disableLandingPageButton to true.
Option To change its icon or text, configure the landingPageName for your defined languages.
If this option isn’t set for a specific language, it will use these default values
For a free configuration of the header menus, see configuration of the sidebar menus.
Option Set showVisitedLinks to true to see checkmarks next to visited pages in the main menu. This also adds a history clearer button at the bottom of the menu to remove all checkmarks.
The visited pages will be stored in the reader’s browser.
If you want to have more control, where the history clearer is positioned or you want to configure a different icon, see the chapter on sidebar configuration.
Note that checkmarks will disappear if you rebuild your site, as the page IDs may change.
To change the menu footer, edit the layouts/partials/menu-footer.html file. Check out the Partials section for more ways to customize your site.
The search term will be stored in the reader’s browser as long as it is present.
The theme offers three levels of search through the menu’s search form:
Each level requires the previous one to be enabled. If no search is configured, the search form won’t appear.
Option All levels are enabled by default. Disable them in your project configuration:
search.disable to truesearch.index.disable to truesearch.page.disable to trueOption Default URLs can be changed with the following parameter
searchindex.js set by search.index.URLsearch/index.html set by search.page.URLYou only need to change these if you have own content created for those URLs. This can happen with uglyURLs set to true in your project configuration and having a content file at content/search.md.
Check for duplicate URLs by running hugo --printPathWarnings.
Option The theme supports different search engines through adapters. Each different adapter may have its own set of configuration.
By default, it uses the Lunr search engine.
lunr is the default search adapter.
Lunr doesn’t support all languages of the theme. Content of an unsupported language is dropped from the search index, so searching it will not return any results. The theme warns you about this during your Hugo build. Currently unsupported are
Option 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 search.adapter.params.additionalContentLanguage to broaden the search.
You can add multiple languages to this array.
Use the base language code. For example, if your page is using zh-CN, add zh to this parameter.
The theme also ships with the additional experimental orama and orama-esm (not usable for headless server deployments) adapters.
Option The search popup loads its index as a script, so your site’s search keeps working when it is opened from the file system. If other tools want to read your index, like an MCP server, set search.index.json to true to additionally write the same data as a plain JSON file.
The JSON file is written next to the search index with the extension .json, for example searchindex.en.json. Its content is minified like the theme’s other assets, depending on the minify option. Its URL stays the same regardless of its content or minification, so other tools can rely on it.
Option You can customize how the search index is generated by specifying a different template:
By default, the theme uses /_relearn_searchindex.json to generate the search index. When you specify a custom value for search.index.template, the theme will look for the template file in your site’s assets directory.
For example, if you set search.index.template to /custom_searchindex.json, you would need to create a file at assets/custom_searchindex.json in your site to define the custom index generation logic.
The template must return the index as JSON. The theme uses it for the search popup as well as for the JSON file, so all search adapters get the same data.
This advanced option is useful if you need to modify how content is indexed or change the structure of the search index to work with custom search implementations.
Option You can customize the appearance of the dedicated search page by changing its content view:
By default, the theme uses _relearn_searchpage as the search content view. When you set search.page.type to a custom value [YOUR-VIEWNAME], Hugo will look for a template file at layouts/[YOUR-VIEWNAME]/article.html.
For example, if you set search.page.type to custom_search_layout, you would need to create a file at layouts/custom_search_layout/article.html in your site to define the custom layout.
This allows you to maintain the search functionality while adapting its appearance to match your specific design requirements.
If your home page has print support activated, your readers can print their search results as well. The search page then shows the print button, and the printed page lists the results for the current search term without the search form.
Option The dedicated search page is not part of your content, so the outputs of your project configuration or of a front matter don’t apply to it. If you want to decide independently of your home page, set its output formats with search.page.outputs.
To never offer printing the search results:
To always offer it:
As long as the option is not set, the print version of the search page is always written to your site, as the theme can not tell at that point whether your home page can be printed. It is just not offered to your readers if it can’t.
In previous versions of the theme, search configuration used flat parameters. The current version uses a more structured approach with a search namespace.
If you’re updating from an older version, here’s how to migrate your search configuration:
| Legacy Parameter | New Parameter |
|---|---|
disableSearch |
search.disable |
disableSearchIndex |
search.index.disable |
disableSearchPage |
search.page.disable |
searchIndexURL |
search.index.URL |
searchPageURL |
search.page.URL |
additionalContentLanguage |
search.adapter.params.additionalContentLanguage |
The theme can build menu trees from the structure of your page files or from Hugo’s build in menu feature.
Option Configuration options in your project configuration apply to all menus.
Front Matter In case of page structure menus, individual configuration is done via a page’s front matter.
. In case of Hugo menus, individual configuration is done via a menu entry’s configuration.
Option Front Matter You can change how submenus appear with alwaysopen.
For Hugo menus, you have to set params.alwaysopen instead.
If alwaysopen is false for any given entry, its children will not be shown in the menu as long as it is not necessary for the sake of navigation.
The theme generates the expand state based on the following rules:
alwaysopen set to falsealwaysopen set to truealwaysopen is true; this proceeds recursivelyOption Front Matter Set collapsibleMenu to true to show submenus as collapsible trees with a clickable expander.
For Hugo menus, you have to set params.collapsibleMenu to true instead.
Using this option may cause degraded build performance by slowing down your build process.
This is usually the case for menus with many entries and happens for page menus as well as for Hugo menus.
We’ve seen builds taking 2 minutes with 1000+ pages, and over 30 minutes with 5000+ pages when using a page menu.
This happens because each new page affects all other pages, leading to exponentially longer build times.
Front Matter Hugo provides a simple way to handle order of your entries taking into account the weight, date and linkTitle front matter .
Hugo menus can only be sorted by weight.
Option Front Matter Use ordersectionsby to sort by other aspects if Hugo’s default sort order does not match your needs. It accepts weight, title, linktitle, lastmod, expirydate, publishdate, date, length or default (adhering to Hugo’s default sort order). Both title and linktitle sort by the title shown in the menu.
Front Matter A page’s linkTitle or title front matter will be used for naming a menu entry of a page menu, in that order if both are defined. Using linkTitle helps to shorten the text for menu entries if the page’s title is too descriptive.
A menu entry’s title or name will be used for naming a menu entry of a Hugo menu, in that order if both are defined.
For example for a page named install/linux.md
Front Matter For page menus, add a menuPre to insert any HTML code before the menu label. You can also set menuPost to insert HTML code after the menu label.
For Hugo menus, add a pre to insert any HTML code before the menu label. You can also set post to insert HTML code after the menu label.
If pageRef is set for the menu entry and no pre or post was configured, menuPre and menuPost of the referenced page will be taken.
The example below uses the GitHub icon for an entry of a page menu.
You may want to structure your entries in a hierarchical way but don’t want to generate clickable parent entries? The theme got you covered.
To stay with the initial example: Suppose you want log/first-day appear in the sidebar but don’t want to generate a page for it. So the entry in the sidebar should not be clickable but should be expandable.
For this, open content/log/first-day/_index.md and add the following front matter
Just don’t give your parent menu entry configuration a url or pageRef. See the next section for a special case.
If you want to learn how to configure different Hugo menus for each language, see the official docs.
The following example will not generate clickable menu entries for the Parent 1 and Parent 2 menu entries.
An entry of a Hugo menu usually ends where your menu definition ends. If you set params.type to page for an entry with a pageRef, the entry is continued by the tree of the page it links to, the same way a page menu starting at that page would show it.
This saves you from repeating your page structure in your menu definition. The entry keeps its own title, pre and post.
If the entry links to a taxonomy page, its terms are shown below it. A term ends the tree, as the pages it lists have their place elsewhere in your menus.
The following example shows all tags of your site below the Tags entry.
By default, the theme supports one additional Hugo menu below the page menu in the sidebar named shortcuts. You only need to configure it in your project configuration to appear in your sidebar. For example:
Option By default, the predefined shortcut menu has a the title More (in the English translation) displayed above it.
You can disable this title by setting disableShortcutsTitle to true.
To change the title, override your translation file.
Each menu may have an optional title above its tree. This must be activated for each menu by setting disableTitle to false for each sidebar menu configuration.
Front Matter For page menus, set the linkTitle front matter for the root page of the menu. For example in the home page for the default sidebar menu. If no linkTitle was set, the title will be taken from your translation files by the key <identifier>-menuTitle, where <identifier> is the identifier of your sidebar menu configuration.
For Hugo menus, the title will be taken from your translation files by the key <identifier>-menuTitle, where <identifier> is the identifier of your sidebar menu configuration.
If you don’t want to fiddle around with your translation files, you also have the possibility to let the title be taken from the menu definition. For that, define a nested menu that only has one top-level entry without url or pageRef.
In this case, the title or name is taken for the menu heading.
If you want to learn how to configure different Hugo menus for each language, see here.
Option Front Matter Menus are defined for individual areas of the sidebar:
sidebarheadermenus: the non-scrolling area below the search boxsidebarmenus: the scrolling area below the search boxsidebarfootermenus: the area at the bottom of the sidebarAs these options are arrays, you can define as many menus, as you like in each area. Each menu is displayed as a distinct block in their area. You can configure titles for each menu and dividers between multiple menus.
If you don’t set these options in your project configuration, the theme defaults as follows:
sidebarheadermenus:
sidebarmenus (depending on the color configuration of the theme variant)sidebarmenus:
shortcuts menu including the title if configured, see notes belowsidebarfootermenus:
sidebarmenus if any of the following is configuredThis comes down to the following pseudo default configuration.
Notes:
homelinks like displayed above, you have to define a Hugo menu to replicate the implicit default configurationshortcuts if the implicit default configuration is active, the value for disableTitle will be determined by your configuration for disableShortcutsTitle.The page menu generates a menu tree out of your directory structure. You can give it a starting page from where the tree is generated down. If no starting page is given, the home page is used.
| Name | Default | Notes |
|---|---|---|
| type | <empty> | page, required |
| identifier | <empty> | Optional with no special meaning besides for error messages |
| main | true |
Whether to add additional spacing and larger text to the menu |
| disableTitle | true |
Whether to print a title above the menu |
| pageRef | / |
The path of the page to start the menu tree |
The Hugo menu generates a menu tree out of a Hugo menu definition with the same identifier.
| Name | Default | Notes |
|---|---|---|
| type | <empty> | menu, required |
| identifier | <empty> | The identifier of the menu definition in your project configuration |
| main | false |
Whether to add additional spacing and larger text to the menu |
| disableTitle | false |
Whether to print a title above the menu; for the predefined shortcuts menu, accounts to the setting of disableShortcutsTitle |
The custom menu allows you to define arbitrary HTML snippets wrapped inside of a li element. There is no title available to print above these menus.
| Name | Default | Notes |
|---|---|---|
| type | <empty> | custom, required |
| identifier | <empty> | Optional with no special meaning besides for error messages |
| main | false |
Whether to add additional spacing and larger text to the menu |
| elements | <empty> | The list of snippets, contained in layouts/partials/sidebar/element, to be displayed. See below. |
An HTML element snippet of a custom menu has its own parameter. Self-defined snippets have further parameters that are passed to your snippet partial when called. Your snippets must be stored in layouts/partials/sidebar/element and the name of the snippet partial needs to be <TYPE>.html where <TYPE> is the type of the element.
| Name | Default | Notes |
|---|---|---|
| type | <empty> | The theme ships with the following snippets: - languageswitcher: will display the language switcher- variantswitcher: will display the variant switcher- versionswitcher: will display the version switcher- historyclearer: will display a button to clear the history of visited links |
| icon | see notes | Font Awesome icon name set to the left of the list entry. Depending on the type there is a default icon. Any given value will overwrite the default. |
A horizontal ruler
| Name | Default | Notes |
|---|---|---|
| type | <empty> | divider |
| identifier | <empty> | Optional with no special meaning besides for error messages |
The following example
If you want to reconfigure the sidebar menus, you have to copy over everything from the default configuration you want to keep as reconfiguration will reset all sidebar menus.
Suppose you are building a site that contains a topmost log and ship section.
When the user is on one of the log pages he should only see a page menu containing all log pages, while on one of the ship pages she should only see a page menu containing all sub pages of the ship section.
For both sections, the default shortcuts Hugo menu should be displayed as if defaults menus were used.
Directory structure:
Option Front Matter Using Hugo’s cascade feature, we can redefine the menus once in log/_index.md and ship/_index.md setting sidebarmenus so they will be used in all children pages.
Setting the sidebarmenus Front Matter will overwrite all default menus. If you want to display the shortcuts Hugo menu as well like in this example, you have to declare it with the Front Matter as given in the default options.
You may have the need to add arbitrary links at some point in your menu that should redirect to other pages in your site structure. These are called crosslinks.
Assume the following structure
You now want to add a top level menu entry that points to third-day as separate crows-nest-incident.
For that create a new page with the following front matter
Front Matter If you want to link to an external page instead, you can use menuUrl instead of menuPageRef.
Pages defining a crosslink are never part of the arrow navigation and are skipped instead.
So with the above example and alphabetical sorting of the menu entries, pressing on kraken-incident page will skip the newly added crows-nest-incident and instead will load burning-sail-incident.
Having sub pages below a page that has menuUrl or menuPageRef set in their front matter is undefined.
Sometimes you want to hide pages from the page menu but instead want to show them in a Hugo menu. For that you have two choices
Create a headless branch bundle, _index.md in its own folder with the below front matter. The branch bundle will not be contained in the sitemap.
Or, put a child page inside a headless branch bundle with the following front matter in the bundle. This causes the child but not the branch bundle to be contained in the sitemap.
The child page can be any type of content.