What are my options to know, which installation I am on - live or development? I want to add debugging (via partial) only on my local running instance, not after deployment.
You need to add HUGO_ENV to your build.
Two ways:
either by adding it to your CLI
$ env HUGO_ENV="production" hugo
Or if you’re on Netlify or other they have their own convenient way to define this.
Then from your templates
{{ getenv "HUGO_ENV" }}
to retrieve the value.
1 Like
Thank you, that did the trick. My final snippet looks like this:
{{ if eq (getenv "HUGO_ENV") "production" }}
{{ partial "footer/debugging.html" . }}
{{ end }}
1 Like
I think you mean ne
rather than eq
3 Likes
haha, you are perfectly right. that was copy paste before check and t(a|e)st.