Help with ENV variables

Hey I was wondering if there was a way to set env variables that can be accessed by my config.toml file…My boss would be happier if, for example, inside my config.toml:

googleAnalytics = “MY G-ID”

was instead something like:
googleAnalytics = env.GoogleAnalyticsID

Thanks for your time!

Think I found what I needed here:

And here:

Sorry for the unnecessary post!

What you want to do is to use Hugo’s naming convention for env variables:


You can set nested config values using the above syntax.


Ahh so in this case, I would do something like,

and also remove
googleAnalytics = “xxxx”

from my config.toml?

The removal from config.toml is optional – the environment variable will always win.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.