# How to use variable in a jekyll liquid loop?

**URL:** <https://talk.jekyllrb.com/t/how-to-use-variable-in-a-jekyll-liquid-loop/7279>\
**Category:** Help\
**Created:** [April 27, 2022, 5:04pm UTC](https://talk.jekyllrb.com/t/how-to-use-variable-in-a-jekyll-liquid-loop/7279 "2022-04-27T17:04:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![taiAmarEiOvinoy](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/taiamareiovinoy/32/4614_2.png) [@taiAmarEiOvinoy](https://talk.jekyllrb.com/u/taiAmarEiOvinoy)\
**Post date:** [April 27, 2022, 5:04pm UTC](https://talk.jekyllrb.com/t/how-to-use-variable-in-a-jekyll-liquid-loop/7279/1 "2022-04-27T17:04:23Z")

</div>

For example,

```auto
{% assign tech = technology %}

```

now I made some post with the category technology. Now I want to loop them like this

```auto
<ul>
                      {% for post in site.categories.tech %}
                          <li>
                              <a>{{post.title}}</a>
                          </li>
                      {% endfor %}
                  </ul>

```

If I do the same procedure but specify the category fully “technology” it works. But whenever I use the variable “tech” it doesn’t work

Please help

---

<div class="post-metadata">

**Author:** ![BillRaymond](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/billraymond/32/5963_2.png) [@BillRaymond](https://talk.jekyllrb.com/u/BillRaymond)\
**Post date:** [April 27, 2022, 8:30pm UTC](https://talk.jekyllrb.com/t/how-to-use-variable-in-a-jekyll-liquid-loop/7279/2 "2022-04-27T20:30:53Z")

</div>

Using Liquid, you think about what you need first, which in your case is `post.title`. That title lives in `site.posts`, so you start by creating an array of posts. When creating the array, you add a filter to inform Jekyll what content you are looking for by using a `where` or `where_exp` filter.

Here is what your final code might look like:

```auto
{%- assign posts = site.posts | where_exp: 'post', 'post.category == tech' -%}
{% for post in posts %}
    <p>Title = {{post.title}}
{% endfor %}

```
