HUGO

Isset doesn't work

Hello everybody,

Someone could tell me why my code doesn’t work ?

{{ if (isset .Params.gCO2e) }}
<div class="blue-impact"><div><a href="{{ .Params.EcoindexLink }}">{{ .Params.gCO2e }} <span 
class="unit">gCO2e</span></a></div></div>
{{ end }}

There is the error message :

render of "section" failed: "/Applications/MAMP/htdocs/Fairness/fairness.coop/layouts/blog/list.html:37:7": execute of template failed: template: blog/list.html:37:7: executing "blog/list.html" at <isset>: wrong number of args for isset: want 2 got 1
Rebuild failed:

Failed to render pages: render of "section" failed: "/Applications/MAMP/htdocs/Fairness/fairness.coop/layouts/blog/list.html:37:7": execute of template failed: template: blog/list.html:37:7: executing "blog/list.html" at <isset>: wrong number of args for isset: want 2 got 1

When i took of the condition, it display well my values.

Thank you :slight_smile:

Hi there,

The error message is quite clear:

Docs for isset: https://gohugo.io/functions/isset/

Do you perhaps mean instead:

{{ if isset .Params "gco2e" }}
1 Like

Ok it works, i was sure that i have tried this before.
Thanks you :sunglasses: