# Checking if items in a yaml file equal one?

**URL:** <https://talk.jekyllrb.com/t/checking-if-items-in-a-yaml-file-equal-one/3024>\
**Category:** Help\
**Created:** [June 26, 2019, 11:57am UTC](https://talk.jekyllrb.com/t/checking-if-items-in-a-yaml-file-equal-one/3024 "2019-06-26T11:57:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![DipperDolphin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/dipperdolphin/32/1549_2.png) [@DipperDolphin](https://talk.jekyllrb.com/u/DipperDolphin)\
**Post date:** [June 26, 2019, 11:57am UTC](https://talk.jekyllrb.com/t/checking-if-items-in-a-yaml-file-equal-one/3024/1 "2019-06-26T11:57:10Z")

</div>

`{% if item in cover.images == 1 %}` doesn’t work. How can I check if there is one item in a list?

Thanks!

---

<div class="post-metadata">

**Author:** ![chuckhoupt](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/chuckhoupt/32/523_2.png) [@chuckhoupt](https://talk.jekyllrb.com/u/chuckhoupt)\
**Post date:** [June 26, 2019, 12:55pm UTC](https://talk.jekyllrb.com/t/checking-if-items-in-a-yaml-file-equal-one/3024/2 "2019-06-26T12:55:49Z")

</div>

> **[size](https://shopify.github.io/liquid/filters/size/)**
>
> Liquid filter that returns the number of characters in a string or the number of items in an array.

---

<div class="post-metadata">

**Author:** ![DipperDolphin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/dipperdolphin/32/1549_2.png) [@DipperDolphin](https://talk.jekyllrb.com/u/DipperDolphin)\
**Post date:** [June 26, 2019, 12:56pm UTC](https://talk.jekyllrb.com/t/checking-if-items-in-a-yaml-file-equal-one/3024/3 "2019-06-26T12:56:09Z")

</div>

Tried that but couldn’t get it to work properly.

---

<div class="post-metadata">

**Author:** ![chuckhoupt](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/chuckhoupt/32/523_2.png) [@chuckhoupt](https://talk.jekyllrb.com/u/chuckhoupt)\
**Post date:** [June 26, 2019, 1:00pm UTC](https://talk.jekyllrb.com/t/checking-if-items-in-a-yaml-file-equal-one/3024/4 "2019-06-26T13:00:44Z")

</div>

The dot-notation form doesn’t work? This assumes `cover.images` is a list/array:

`{% if cover.images.size == 1 %}`

---

<div class="post-metadata">

**Author:** ![DipperDolphin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/dipperdolphin/32/1549_2.png) [@DipperDolphin](https://talk.jekyllrb.com/u/DipperDolphin)\
**Post date:** [June 26, 2019, 1:01pm UTC](https://talk.jekyllrb.com/t/checking-if-items-in-a-yaml-file-equal-one/3024/5 "2019-06-26T13:01:33Z")

</div>

This is in the yaml:

```auto
images:
  - image: 'static/images/covers/doctor.jpeg'
  - image: 'static/images/covers/hello.jpeg'

```

Tried that, but didn’t work.

---

<div class="post-metadata">

**Author:** ![chuckhoupt](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/chuckhoupt/32/523_2.png) [@chuckhoupt](https://talk.jekyllrb.com/u/chuckhoupt)\
**Post date:** [June 26, 2019, 1:14pm UTC](https://talk.jekyllrb.com/t/checking-if-items-in-a-yaml-file-equal-one/3024/6 "2019-06-26T13:14:44Z")

</div>

Below is an example using the YAML data (tested and working). Is it possible that `cover.images` isn’t returning the array you expect? You might check with `{{ cover.images | inspect }}` to verify its contents.

test.md:

```auto
---
images:
  - image: 'static/images/covers/doctor.jpeg'
  - image: 'static/images/covers/hello.jpeg'
---

Size: {{ page.images.size }}

There are
{%- if page.images.size == 1 %} One {% endif %}
{%- if page.images.size == 2 %} Two {% endif %}
images.

```

---

<div class="post-metadata">

**Author:** ![DipperDolphin](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/dipperdolphin/32/1549_2.png) [@DipperDolphin](https://talk.jekyllrb.com/u/DipperDolphin)\
**Post date:** [June 26, 2019, 1:15pm UTC](https://talk.jekyllrb.com/t/checking-if-items-in-a-yaml-file-equal-one/3024/7 "2019-06-26T13:15:09Z")

</div>

Worked, thanks so much!
