Override config files

I know that I can use multiple config files via

hugo --config a.toml,b.toml,c.toml

but is it possible to define such a chain via the main config.toml file? If not, wouldn’t that be a good feature?

I wouldn’t use it, so I couldn’t say. Do many folks chain configs together?

Would using the config dir meet your needs: https://gohugo.io/getting-started/configuration/#configuration-directory

The idea is to provide a “theme component” and then let the user override specific setups.

That one is new to me. It might help my idea if this would work with themes config dirs overriding each other. If it has to be in one single directory (as it seems to be the case) it’s not really working.

Would you explain more what you mean by this?

Well, we have theme components. If my component establishes a config variable bla.fasel with a default value of 900px it would be nice if another component or the (final) theme based on my component itself would be able to override it with a 860px for instance.

The same way multiple entries in the theme config line would override each other, just using config.toml.

The main idea is to just “drop in” my theme component without the people using it being required to read docs and add stuff to their configs. But IF THEY WANT they can do so by adding items to their own config.

I see. I handle this by specifying a default value for configurable params. So if a user doesn’t specify a value, no worries.

https://gohugo.io/functions/default/#readout

2 Likes

Very useful. Thanks.