docs/content/en/functions/os/Getenv.md
By default, when using the os.Getenv function Hugo allows access to:
CI environment variableHUGO_To access other environment variables, adjust your project configuration. For example, to allow access to the HOME and USER environment variables:
{{< code-toggle file=hugo >}} [security.funcs] getenv = ['^HUGO_', '^CI$', '^USER$', '^HOME$'] {{< /code-toggle >}}
For more information see configure security.
{{ getenv "HOME" }} → /home/victor
{{ getenv "USER" }} → victor
You can pass values when building your project:
MY_VAR1=foo MY_VAR2=bar hugo
OR
export MY_VAR1=foo
export MY_VAR2=bar
hugo
And then retrieve the values within a template:
{{ getenv "MY_VAR1" }} → foo
{{ getenv "MY_VAR2" }} → bar