Importing other configuration files

Hello, I discovered Hugo recently and have been reading the documentation, this forum, existing tutorials and browsing through existing themes, trying to learn the in and outs. I can see that Hugo is a fantastic framework, but I must echo the frustration of forum posts due to a lack of comprehensive tutorials…hopefully I can contribute after I get a better understanding.

I’m making a multilingual site from scratch, separating content using the directory method and trying to make my own theme.

The themes documentation says that themes can define menus in its own configuration file. On the getting-started/configuration page, there’s a screenshot showing various configuration files such as languages.toml, menus.en.toml, menus.zh.toml in addition to config.toml. I made languages.toml in my site’s config folder, and the menu config files in my themes/<theme_name>/config folder and set the corresponding configurations…but currently, I have to put all the configurations in config.toml.

So I have a few questions:

  • How can I import configuration into config.toml?

  • Do I have to define [menu] and some [[menu.main]] entries in config.toml and so that Hugo knows how and what menu entry to substitute when it looks in language-specific menu configurations like [[]]?

  • Do language-specific menu configurations have to reside directly under the [languages] configuration? From the screenshot in getting-started/configuration (under Configuration Directory), it seems that language-specific menu configurations and language configuration can be separate.

The code I’m using to show the menu on my webpage is

  {{ range .Site.Menus.main }}
        <a href="{{ .URL | relLangURL }}" class="link">{{ .Name }}</a>
{{ end }}

Thank you in advance!

1 Like

I know you can specify multiple configurations when you build, like:

/path/to/my/project> hugo --config a.toml,b.toml,c.toml

By default, you can put all your configuration files in config/_default and Hugo will load all those files

I think you can use themes/theme-name/config/_default but wouldn’t it make more sense to have configuration under the project root rather than the theme? (The documentation doesn’t explicitly list the lookup order for config files, but says it’s similar to how the template lookup.)

1 Like