# Isset function adding whitespace if false

**URL:** <https://discourse.gohugo.io/t/isset-function-adding-whitespace-if-false/23322>\
**Category:** Uncategorized\
**Created:** [February 8, 2020, 6:33am UTC](https://discourse.gohugo.io/t/isset-function-adding-whitespace-if-false/23322 "2020-02-08T06:33:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhishalya](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/abhishalya/32/10257_2.png) [@abhishalya](https://discourse.gohugo.io/u/abhishalya)\
**Post date:** [February 8, 2020, 6:33am UTC](https://discourse.gohugo.io/t/isset-function-adding-whitespace-if-false/23322/1 "2020-02-08T06:33:17Z")

</div>

I’m trying to add content as follows:

```auto
{{ if isset .Params "journal" }}<i>{{- .Params.journal -}}</i>{{ end }}
{{ if isset .Params "booktitle" }}<i>{{- .Params.booktitle -}}</i>{{ end }}
{{ if isset .Params "volume" }}{{- .Params.volume -}}{{ end }}
{{ if isset .Params "issue" }}({{- .Params.issue -}}){{ end }}

```

The rendered version adds whitespace if the `isset` is evaluated to false. Is there any way I can avoid this?

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [February 8, 2020, 8:06am UTC](https://discourse.gohugo.io/t/isset-function-adding-whitespace-if-false/23322/2 "2020-02-08T08:06:52Z")

</div>

See:

> **[Introduction to Hugo Templating](https://gohugo.io/templates/introduction/#whitespace)**
>
> Hugo uses Go's \`html/template\` and \`text/template\` libraries as the basis for the templating.

---

<div class="post-metadata">

**Author:** ![marcellmars](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/marcellmars/32/10931_2.png) [@marcellmars](https://discourse.gohugo.io/u/marcellmars)\
**Post date:** [April 1, 2020, 11:55am UTC](https://discourse.gohugo.io/t/isset-function-adding-whitespace-if-false/23322/3 "2020-04-01T11:55:08Z")

</div>

it is probably intuitive for many but it was not for me so if you want to avoid any whitespace character you should add dash to every part of the if-then close so {{- if … -}} **and** {{- end -}} should also have the dashes and to be sure if you have the long list of if-then clauses do that for the ones outlining too (or short: do it for every {{ if }}/{{ end }} you can find in your templates until it breaks ;))…

i tried to find a good source of the behavior of the dashes in templates with a lot of logical blocks but so far couldn’t find the good specification… most of the references are just mentioning the case in which the variable is in between the {{ brackets }}… for the time being before doing a proper set of tests i would stick to making my habit into {{- -}} instead of {{ }}…
