Read Google Analytics Tracking ID from environment

Hi guys,

I’m trying to add Google Analytics to my page using an environment variable. I have added a “HUGO_GOOGLE_ANALYTICS” environment variable, but it doesn’t seem to be picked up by Hugo.

I’m using the Minimo theme, and left the key googleAnalytics = "" as I assume that the environment variable would take precedence.

Am I doing this right?

Have you tried using getenv in your template, where you want that value to appear?

 {{ getenv "HUGO_SOMEVAR" }}

The spelling matters, try: HUGO_GOOGLEANALYTICS