# True and false

When a non-Boolean data type is used in a Boolean context (for example in a conditional tag), Liquid decides whether it counts as true or false.

When a non-Boolean [data type](https://developer.versacommerce.de/articles/liquid-basics-types) is used in a Boolean context (for example in a conditional tag), Liquid decides whether it counts as `true` or `false`. Values that count as `true` are called **truthy**. Values that count as `false` are called **falsy**.

## Truthy

All values in Liquid are truthy except `nil` and `false`.

In this example, the text "Tobi" is not a Boolean, but it is truthy in a condition:

```liquid
{% assign name = "Tobi" %}

{% if name %}
  This text is always shown when "name" is defined.
{% endif %}
```

Empty [strings](https://developer.versacommerce.de/articles/liquid-basics-types#string) are truthy. The following example outputs empty HTML tags if `settings.fp_heading` exists but is empty:

```liquid
{% if settings.fp_heading %}
  <h1>{{ settings.fp_heading }}</h1>
{% endif %}
```

```html
<h1></h1>
```

To avoid this, check whether the string is `blank`:

```liquid
{% unless settings.fp_heading == blank %}
    <h1>{{ settings.fp_heading }}</h1>
{% endunless %}
```

An [EmptyDrop](https://developer.versacommerce.de/articles/liquid-basics-types#emptydrop) is truthy as well. In the following example, you get an EmptyDrop if `settings.page` is an empty string or points to a hidden or deleted object. The result is an unwanted empty `<div>`.

Input:

```liquid
{% if pages[settings.page] %}

 <div>
  {{ pages[settings.page].content }}
 </div>
{% endif %}
```

Output:

```html
 <div></div>
```

## Falsy

The only falsy values in Liquid are `nil` and `false`.

[nil](https://developer.versacommerce.de/articles/liquid-basics-types#nil) is returned when a Liquid object has nothing to return. For example, if a collection has no image, `collection.image` is `nil`. Because that is falsy, you can write:

```liquid
{% if collection.image %}

 <!-- output collection image -->
{% endif %}
```

The value `false` is returned by many object properties, for example `product.available`.
