# Where should I store API keys?

**URL:** <https://discourse.gohugo.io/t/where-should-i-store-api-keys/903>\
**Category:** support\
**Created:** [March 15, 2015, 7:15pm UTC](https://discourse.gohugo.io/t/where-should-i-store-api-keys/903 "2015-03-15T19:15:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cgray9](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/cgray9/32/305_2.png) [@cgray9](https://discourse.gohugo.io/u/cgray9)\
**Post date:** [March 15, 2015, 7:15pm UTC](https://discourse.gohugo.io/t/where-should-i-store-api-keys/903/1 "2015-03-15T19:15:56Z")

</div>

I currently have my API key stored in config.tml file as a param. However, I don’t want to commit that file to source control as it has an API key in it. Can the the config file read in Environmental variables? If so how? Not sure the best way to do this.

---

<div class="post-metadata">

**Author:** ![michael\_henderson](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/michael_henderson/32/10490_2.png) [@michael\_henderson](https://discourse.gohugo.io/u/michael_henderson)\
**Post date:** [March 15, 2015, 8:34pm UTC](https://discourse.gohugo.io/t/where-should-i-store-api-keys/903/2 "2015-03-15T20:34:53Z")

</div>

Go templates have `{{ getenv "FOO" }}` but Hugo doesn’t seem to export that function.

Related [http://discuss.gohugo.io/t/how-do-i-get-environment-variables-in-the-template/597](http://discuss.gohugo.io/t/how-do-i-get-environment-variables-in-the-template/597)

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 15, 2015, 8:46pm UTC](https://discourse.gohugo.io/t/where-should-i-store-api-keys/903/3 "2015-03-15T20:46:51Z")

</div>

I don’t think Go templates has a getenv func (if it did, it would work), but Hugo should. PRs are welcome.

---

<div class="post-metadata">

**Author:** ![michael\_henderson](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/michael_henderson/32/10490_2.png) [@michael\_henderson](https://discourse.gohugo.io/u/michael_henderson)\
**Post date:** [March 15, 2015, 9:01pm UTC](https://discourse.gohugo.io/t/where-should-i-store-api-keys/903/4 "2015-03-15T21:01:14Z")

</div>

Working on trying to merge [https://github.com/kelseyhightower/confd/issues/149](https://github.com/kelseyhightower/confd/issues/149) into but having some problems.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 15, 2015, 9:33pm UTC](https://discourse.gohugo.io/t/where-should-i-store-api-keys/903/5 "2015-03-15T21:33:02Z")

</div>

I wouldn’t try to merge it - just add the getenv as a template func in Hugo’s template.go that delegates to Go’s builtin function.

---

<div class="post-metadata">

**Author:** ![anweiss](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/anweiss/32/606_2.png) [@anweiss](https://discourse.gohugo.io/u/anweiss)\
**Post date:** [August 12, 2015, 3:55pm UTC](https://discourse.gohugo.io/t/where-should-i-store-api-keys/903/6 "2015-08-12T15:55:06Z")

</div>

Hey @cgray9, how did you end up loading your environment variable with the `getenv` template function? I didn’t think the site config could parse Go template syntax.
