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!

Edit:
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:

HUGO_GOOGLEANALYTICS=xxxx

You can set nested config values using the above syntax.

2 Likes

Ahh so in this case, I would do something like,
HUGO_GOOGLEANALYTICS=xxxx`
export HUGO_GOOGLEANALYTICS

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.