How to check if a variable is set

Hi, how are you?
I need some help. I want to be able to check if a variable(.link) is set or if is blank then display the link.
Basically, i’d like to show a button when there’s a specified link and no button if it isn’t(blank/nill).
How can I do this. The link in question is in a data file and the way I call it is using {{ .link | absUrl }} and there are multiple entries

I am a title

I am the content
img: image/img1.jpg
link: /i-am-a-link/link1

I am a title2

I am the content2
img: image/img2.jpg
link: /i-am-a-link/link2

{{ $a := "foo" }}
{{ with $a }}
  _{{ . }}_ => "_foo_"
{{ end }}

{{ $b := "" }}
{{ with $b }}
  _{{ . }}_ => nothing rendered
{{ end }}

{{ with $c }}
  _{{ . }}_ => nothing rendered
{{ end }}

See with under

1 Like

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