Notes

Hugo Config Directories

Edit on GitHub

Hugo
2 minutes
  • The file is named after a configuration root object. Root objects are the ones that have a single square bracket. For example: [module], [menu], [Params] etc. These you can split into their own files, named after the object. For example: module.toml, menu.toml or menus.toml, params.toml etc.
  • Since the files are named after the root object, you’d skip mentioning the root object itself, i.e. the config will be top-level.

Code samples

Here’s a chunk of configuration from the config.toml file

 1# config.toml
 2
 3[menu]
 4[[menu.main]]
 5  name = 'Home'
 6  pre = "<i class='ri ri-home-line'></i>"
 7  url = '/'
 8  weight = -110
 9  
10[[menu.main]]
11  name = 'About'
12  pre = "<i class='ri ri-aliens-line'></i>"
13  url = '/about'
14  weight = -110
15  
16[[menu.main]]
17  name = 'Work'
18  pre = "<i class='ri ri-apps-line'></i>"
19  url = '/work'
20  weight = -110
21  
22[[menu.main]]
23  name = 'Contact'
24  pre = "<i class='ri ri-mail-unread-line'></i>"
25  url = '/contact'
26  weight = -110
27
28[module]
29[[module.imports]]
30path = "github.com/theNewDynamic/gohugo-theme-ananke"
31disabled = false
32
33[[module.imports]]
34  # import this repo as a Hugo module
35  path = "github.com/aamnah/notes"
36  disabled = false
37
38  # mount the imported repo in this location
39  [[imports.mounts]]
40  # root of repo can be specified with `.`
41  # if bringing in a subdirectory, mention the subdriectory path in source
42  source = "."
43  target = "content/notes"

This can be split into module.toml and menus.toml like so:

 1# module.toml
 2[[imports]]
 3  path = "github.com/theNewDynamic/gohugo-theme-ananke"
 4  disable = false
 5
 6[[imports]]
 7  # import this repo as a Hugo module
 8  path = "github.com/aamnah/notes"
 9  disable = false
10
11  # mount the imported repo in this location
12  [[imports.mounts]]
13  # root of repo can be specified with `.`
14  # if bringing in a subdirectory, mention the subdriectory path in source
15  source = "."
16  target = "content/notes"
 1# menus.toml
 2[[main]]
 3  name = 'Home'
 4  pre = "<i class='ri ri-home-line'></i>"
 5  url = '/'
 6  weight = -110
 7  
 8[[main]]
 9  name = 'About'
10  pre = "<i class='ri ri-aliens-line'></i>"
11  url = '/about'
12  weight = -110
13  
14[[main]]
15  name = 'Work'
16  pre = "<i class='ri ri-apps-line'></i>"
17  url = '/work'
18  weight = -110
19  
20[[main]]
21  name = 'Contact'
22  pre = "<i class='ri ri-mail-unread-line'></i>"
23  url = '/contact'
24  weight = -110

Here’s a YAML sample

1main:
2- name: "Google"
3  url: "https://www.google.com"
4- name: "Yahoo"
5  url: "https://www.yahoo.com"