Setting a Parameter in a Theme

Short version: Is it possible to set a parameter in a theme? (is there an equivalent to config.toml for a theme?)

Longer version:

In every site, I do some of the same things in the config.toml, so I’d like to move those into the theme.

In the ideal case, I could have a config.toml in my theme, which sets parameters. These could then be over-written by the site’s config.toml. I would want both the theme and the site config to be applied (with the site being applied last).

The closest answer I see is:

which suggests the answer is no.

The goal is not only to simplify the sites (and put more of the work into the theme), but also to allow for quick update of many sites that share the theme (rather than trying to remember to change all of the config.toml in each site).

Adding to the complexity:

I have created an “overlay theme” that I load before a regular theme, so I have a line:

theme = [“559Theme”,“Mainroad”]

I’d like the config.toml in 559Theme to set parameters used by mainroad (so I don’t have to remember to do this for each site)

Suggestions are appreciated.

mike

In your theme there are configuration files. Either config.toml or a folder config with subfolders with configuration. You add parameters to the [params] section and they will be available as site.Params.yourParameterName.

People using your theme can override it in their own configuration files.

1 Like

I’m pretty sure to be out of scope, but have you look at the Configuration directory option? It’s maybe a lead to manage several config with the theme(s) as setting.

Yes, but note that we improved this situation drastically in Hugo 0.84, see Config Revamp | Hugo

1 Like

Thank you. That (config directories) is a useful thing, but I am not sure it addresses the issue.

Thanks! That will help with the things I need!

I am not sure why it didn’t work in my initial experiments (I tried creating a config.toml in the theme, I will try again). But, when I tried it again this morning, it did work just fine.

It also seems like this is a new feature. (I had upgraded to a new enough version).

Thanks again to everyone!