# Can't give argument to non-function getenv

**URL:** <https://discourse.gohugo.io/t/cant-give-argument-to-non-function-getenv/27448>\
**Category:** support\
**Created:** [August 9, 2020, 3:36am UTC](https://discourse.gohugo.io/t/cant-give-argument-to-non-function-getenv/27448 "2020-08-09T03:36:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [August 9, 2020, 3:36am UTC](https://discourse.gohugo.io/t/cant-give-argument-to-non-function-getenv/27448/1 "2020-08-09T03:36:55Z")

</div>

```auto
<(getenv "HUGO_ENV") eq "production">: can't give argument to non-function getenv "HUGO_ENV"

```

I was digging around to find out, how this error might come up. Using the latest version at this time:

```auto
Hugo Static Site Generator v0.74.3-DA0437B4/extended linux/amd64 BuildDate: 2020-07-23T16:30:30Z

```

These lines:

```auto
   10: {{ if (getenv "HUGO_ENV") eq "production" }}
   11 {{ template "_internal/google_analytics.html" . }}
   12 {{ end }}

```

in `_baseof.html` lead to plenty of these errors and stop site compilation. I read [this](https://discourse.gohugo.io/t/0-71-1-error-cant-give-argument-to-non-function/25928/3) and some other posts about this kind of error, but I fail to “get it” in regards to my code line.

Can someone please enlighten me what the problem is here? It worked back in 0.53 (one of these older pages) and in other more current posts I see `getenv` used quite often, so it’s not a deprecated function.

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [August 9, 2020, 3:50am UTC](https://discourse.gohugo.io/t/cant-give-argument-to-non-function-getenv/27448/2 "2020-08-09T03:50:32Z")

</div>

> [@davidsneighbour](#):
>
> `{{ if (getenv "HUGO_ENV") eq "production" }}`

```auto
{{ if eq (getenv "HUGO_ENV") "production" }}

```

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [August 9, 2020, 4:10am UTC](https://discourse.gohugo.io/t/cant-give-argument-to-non-function-getenv/27448/3 "2020-08-09T04:10:14Z")

</div>

well, thankyou 🙂 this was a typical forest vs tree moment 😃

---

<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:** [August 9, 2020, 10:38am UTC](https://discourse.gohugo.io/t/cant-give-argument-to-non-function-getenv/27448/4 "2020-08-09T10:38:06Z")

</div>

I would recommend `hugo.IsProduction` for this – it does pick up `HUGO_ENV` or `HUGO_ENVIRONMENT` etc.

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [August 10, 2020, 2:13pm UTC](https://discourse.gohugo.io/t/cant-give-argument-to-non-function-getenv/27448/5 "2020-08-10T14:13:59Z")

</div>

> [@bep](#):
>
> hugo.IsProduction

I used that and it works well… Perfect.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [August 12, 2020, 2:14pm UTC](https://discourse.gohugo.io/t/cant-give-argument-to-non-function-getenv/27448/6 "2020-08-12T14:14:04Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
