# How to get configuration environment being used in template?

**URL:** <https://discourse.gohugo.io/t/how-to-get-configuration-environment-being-used-in-template/23029>\
**Category:** support\
**Created:** [January 25, 2020, 4:45pm UTC](https://discourse.gohugo.io/t/how-to-get-configuration-environment-being-used-in-template/23029 "2020-01-25T16:45:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PawelUrbanski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pawelurbanski/32/9202_2.png) [@PawelUrbanski](https://discourse.gohugo.io/u/PawelUrbanski)\
**Post date:** [January 25, 2020, 4:45pm UTC](https://discourse.gohugo.io/t/how-to-get-configuration-environment-being-used-in-template/23029/1 "2020-01-25T16:45:34Z")

</div>

Hi Everyone,  
I created a directory called: “staging” inside my: “config” folder. The documentation says that when Hugo is run without any flags its environment defaults to: “production”, when it is run with: Hugo server the environment is: “development”.

I would like to check what kind of environment is currently in context, for example:  
Hugo --environment staging

How can I check if it is “staging” or “production”?  
Using: {{ if eq (getenv “HUGO\_ENV”) “production” -}} does nto work, for I guess it is for checking system environment variables.

Thanks for help in advance,  
Pawel

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [January 25, 2020, 5:59pm UTC](https://discourse.gohugo.io/t/how-to-get-configuration-environment-being-used-in-template/23029/2 "2020-01-25T17:59:08Z")

</div>

`{{ .Hugo.Environment }}`

See: [https://gohugo.io/variables/hugo/](https://gohugo.io/variables/hugo/)

---

<div class="post-metadata">

**Author:** ![PawelUrbanski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pawelurbanski/32/9202_2.png) [@PawelUrbanski](https://discourse.gohugo.io/u/PawelUrbanski)\
**Post date:** [January 25, 2020, 8:03pm UTC](https://discourse.gohugo.io/t/how-to-get-configuration-environment-being-used-in-template/23029/3 "2020-01-25T20:03:46Z")

</div>

Thank you Maiki,  
Addint a note due to the upcoming change in Hugo’s API:  
hugo.Environment will be the correct call.  
P.S.: Unless, there will be some future change in the API itself.

---

<div class="post-metadata">

**Author:** ![chloe-the-catgirl](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/chloe-the-catgirl/32/19613_2.png) [@chloe-the-catgirl](https://discourse.gohugo.io/u/chloe-the-catgirl)\
**Post date:** [June 6, 2023, 8:51am UTC](https://discourse.gohugo.io/t/how-to-get-configuration-environment-being-used-in-template/23029/4 "2023-06-06T08:51:09Z")

</div>

In case, someone from the future is stumbling upon this entry: it’s now solved using the [`hugo` function](https://gohugo.io/functions/hugo/) and therefore it is: `{{ hugo.Environment }}`

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [June 6, 2023, 2:34pm UTC](https://discourse.gohugo.io/t/how-to-get-configuration-environment-being-used-in-template/23029/5 "2023-06-06T14:34:47Z")

</div>


