2023-08-19 13:42:59 +01:00
---
title: Configuration
weight: 2
---
Hugo reads its configuration from `hugo.yaml` in the root of your Hugo site.
The config file is where you can configure all aspects of your site.
2023-10-21 17:18:04 -04:00
Check out the config file for this site [`exampleSite/hugo.yaml` ](https://github.com/imfing/hextra/blob/main/exampleSite/hugo.yaml ) on GitHub to get a comprehensive idea of available settings and best practices.
2023-08-19 13:42:59 +01:00
2023-08-27 23:44:43 +01:00
<!-- more -->
2023-08-19 13:42:59 +01:00
## Navigation
### Menu
Top right menu is defined under the `menu.main` section in the config file:
```yaml {filename="hugo.yaml"}
menu:
main:
- name: Documentation
pageRef: /docs
weight: 1
- name: Blog
pageRef: /blog
weight: 2
- name: About
pageRef: /about
weight: 3
- name: Search
weight: 4
params:
type: search
- name: GitHub
weight: 5
url: "https://github.com/imfing/hextra"
params:
icon: github
```
There are different types of menu items:
1. Link to a page in the site with `pageRef`
```yaml
- name: Documentation
pageRef: /docs
```
2. Link to an external URL with `url`
```yaml
- name: GitHub
url: "https://github.com"
```
3. Search bar with `type: search`
```yaml
- name: Search
params:
type: search
```
4. Icon
```yaml
- name: GitHub
params:
icon: github
```
These menu items can be sorted by setting the `weight` parameter.
2023-09-06 04:15:05 +05:30
### Logo and Title
To modify the default logo, edit `hugo.yaml` and add the path to your logo file under `static` directory.
Optionally, you can change the link that users are redirected to when clicking on your logo, as well as set the width & height of the logo in pixels.
```yaml {filename="hugo.yaml"}
params:
navbar:
displayTitle: true
displayLogo: true
logo:
path: images/logo.svg
dark: images/logo-dark.svg
link: /
width: 40
height: 20
```
2023-08-19 13:42:59 +01:00
## Sidebar
### Main Sidebar
For the main sidebar, it is automatically generated from the structure of the content directory.
See the [Organize Files ](/docs/guide/organize-files ) page for more details.
2023-11-17 18:00:05 -05:00
To exclude a single page from the left sidebar, set the `sidebar.exclude` parameter in the front matter of the page:
```yaml {filename="content/docs/guide/configuration.md"}
---
title: Configuration
sidebar:
exclude: true
---
```
2023-08-19 13:42:59 +01:00
### Extra Links
Sidebar extra links are defined under the `menu.sidebar` section in the config file:
```yaml {filename="hugo.yaml"}
menu:
sidebar:
- name: More
params:
type: separator
weight: 1
- name: "About"
pageRef: "/about"
weight: 2
- name: "Hugo Docs ↗"
url: "https://gohugo.io/documentation/"
weight: 3
```
## Right Sidebar
### Table of Contents
Table of contents is automatically generated from the headings in the content file. It can be disabled by setting `toc: false` in the front matter of the page.
```yaml {filename="content/docs/guide/configuration.md"}
---
title: Configuration
toc: false
---
```
### Page Edit Link
To configure the page edit link, we can set the `params.editURL.base` parameter in the config file:
```yaml {filename="hugo.yaml"}
params:
editURL:
2024-01-08 13:22:15 -05:00
enable: true
2023-08-19 13:42:59 +01:00
base: "https://github.com/your-username/your-repo/edit/main"
```
2023-10-27 17:39:31 +08:00
The edit links will be automatically generated for each page based on the provided url as root directory.
2023-11-21 14:50:29 -06:00
If you want to set edit link for a specific page, you can set the `editURL` parameter in the front matter of the page:
2023-08-19 13:42:59 +01:00
```yaml {filename="content/docs/guide/configuration.md"}
---
title: Configuration
2023-11-21 14:50:29 -06:00
editURL: "https://example.com/edit/this/page"
2023-08-19 13:42:59 +01:00
---
```
2023-09-01 14:19:14 -07:00
## Footer
### Copyright
2023-09-01 17:38:49 -04:00
To modify the copyright text displayed in your website's footer, you'll need to create a file named `i18n/en.yaml` .
In this file, specify your new copyright text as shown below:
2023-09-01 14:19:14 -07:00
```yaml {filename="i18n/en.yaml"}
2024-04-17 21:36:25 +00:00
copyright: "© 2024 YOUR TEXT HERE"
2023-09-01 14:19:14 -07:00
```
2023-09-01 17:38:49 -04:00
For your reference, an example [`i18n/en.yaml` ](https://github.com/imfing/hextra/blob/main/i18n/en.yaml ) file can be found in the GitHub repository. Additionally, you could use Markdown format in the copyright text.
2023-09-06 04:15:05 +05:30
## Others
### Favicon
2023-09-11 17:15:24 -04:00
To customize the [favicon ](https://en.wikipedia.org/wiki/Favicon ) for your site, place icon files under the `static` folder to override the [default favicons from the theme ](https://github.com/imfing/hextra/tree/main/static ):
{{< filetree / container > }}
{{< filetree / folder name = "static" > }}
{{< filetree / file name = "android-chrome-192x192.png" > }}
{{< filetree / file name = "android-chrome-512x512.png" > }}
{{< filetree / file name = "apple-touch-icon.png" > }}
{{< filetree / file name = "favicon-16x16.png" > }}
{{< filetree / file name = "favicon-32x32.png" > }}
{{< filetree / file name = "favicon-dark.svg" > }}
{{< filetree / file name = "favicon.ico" > }}
{{< filetree / file name = "favicon.svg" > }}
{{< filetree / file name = "site.webmanifest" > }}
{{< /filetree/folder >}}
{{< /filetree/container >}}
2024-09-22 22:41:07 +01:00
Include `favicon.ico` , `favicon.svg` and `favicon-dark.svg` files in your project to ensure your site's favicons display correctly.
2023-09-11 17:15:24 -04:00
2024-09-22 22:41:07 +01:00
While `favicon.ico` is generally for older browsers, `favicon.svg` and `favicon-dark.svg` are supported by modern browsers.
Use tools like [favicon.io ](https://favicon.io/ ) or [favycon ](https://github.com/ruisaraiva19/favycon ) to generate such icons.
2023-09-20 23:36:00 +01:00
2023-10-21 17:18:04 -04:00
### Theme Configuration
Use the `theme` setting to configure the default theme mode and toggle button, allowing visitors to switch between light or dark mode.
```yaml {filename="hugo.yaml"}
params:
theme:
# light | dark | system
default: system
displayToggle: true
```
Options for `theme.default` :
- `light` - always use light mode
- `dark` - always use dark mode
- `system` - sync with the operating system setting (default)
The `theme.displayToggle` parameter allows you to display a toggle button for changing themes.
When set to `true` , visitors can switch between light or dark mode, overriding the default setting.
2023-09-20 23:36:00 +01:00
2025-01-23 21:58:03 +01:00
### Page Last Modification
The date of the page's last modification can be displayed by enabling the `params.displayUpdatedDate` flag. To use Git commit date as the source, enable also the `enableGitInfo` flag.
To customize the date format, set the `params.dateFormat` parameter. Its layout matches Hugo's [`time.Format` ](https://gohugo.io/functions/time/format/ ).
```yaml {filename="hugo.yaml"}
# Parse Git commit
enableGitInfo: true
params:
# Display the last modification date
displayUpdatedDate: true
dateFormat: "January 2, 2006"
```
2023-09-20 23:36:00 +01:00
### Page Width
The width of the page can be customized by the `params.page.width` parameter in the config file:
```yaml {filename="hugo.yaml"}
params:
page:
# full (100%), wide (90rem), normal (1280px)
width: wide
```
2023-10-21 17:18:04 -04:00
There are three available options: `full` , `wide` , and `normal` . By default, the page width is set to `normal` .
2023-09-20 23:36:00 +01:00
Similarly, the width of the navbar and footer can be customized by the `params.navbar.width` and `params.footer.width` parameters.
2023-09-21 08:03:35 +01:00
2023-10-21 16:00:39 -04:00
### Search Index
Full-text search powered by [FlexSearch ](https://github.com/nextapps-de/flexsearch ) is enabled by default.
To customize the search index, set the `params.search.flexsearch.index` parameter in the config file:
```yaml {filename="hugo.yaml"}
params:
# Search
search:
enable: true
type: flexsearch
flexsearch:
# index page by: content | summary | heading | title
index: content
```
2023-10-21 17:18:04 -04:00
Options for `flexsearch.index` :
2023-10-21 16:00:39 -04:00
- `content` - full content of the page (default)
- `summary` - summary of the page, see [Hugo Content Summaries ](https://gohugo.io/content-management/summaries/ ) for more details
- `heading` - level 1 and level 2 headings
- `title` - only include the page title
2024-06-02 20:53:38 +08:00
To customize the search tokenize, set the `params.search.flexsearch.tokenize` parameter in the config file:
```yaml {filename="hugo.yaml"}
params:
# ...
flexsearch:
# full | forward | reverse | strict
tokenize: forward
```
Options for [`flexsearch.tokenize` ](https://github.com/nextapps-de/flexsearch/#tokenizer-prefix-search ):
- `strict` - index whole words
- `forward` - incrementally index words in forward direction
- `reverse` - incrementally index words in both directions
- `full` - index every possible combination
2023-10-21 16:00:39 -04:00
To exclude a page from the search index, set the `excludeSearch: true` in the front matter of the page:
```yaml {filename="content/docs/guide/configuration.md"}
---
title: Configuration
excludeSearch: true
---
```
2023-09-21 08:03:35 +01:00
### Google Analytics
2023-10-30 19:48:48 -04:00
To enable [Google Analytics ](https://marketingplatform.google.com/about/analytics/ ), set `services.googleAnalytics.ID` flag in `hugo.yaml` :
2023-09-21 08:03:35 +01:00
```yaml {filename="hugo.yaml"}
2023-10-30 19:48:48 -04:00
services:
googleAnalytics:
ID: G-MEASUREMENT_ID
2023-09-21 08:03:35 +01:00
```