--- title: 'Liquid objects: forloop' description: 'Information about a parent [`for` loop](/docs/api/liquid/tags/for).' api_name: liquid source_url: html: 'https://shopify.dev/docs/api/liquid/objects/forloop' md: 'https://shopify.dev/docs/api/liquid/objects/forloop.md' --- # forloop Information about a parent [`for` loop](https://shopify.dev/docs/api/liquid/tags/for). ## Properties * * first [boolean](https://shopify.dev/docs/api/liquid/basics#boolean) * Returns `true` if the current iteration is the first. Returns `false` if not. * index [number](https://shopify.dev/docs/api/liquid/basics#number) * The 1-based index of the current iteration. * index0 [number](https://shopify.dev/docs/api/liquid/basics#number) * The 0-based index of the current iteration. * last [boolean](https://shopify.dev/docs/api/liquid/basics#boolean) * Returns `true` if the current iteration is the last. Returns `false` if not. * length [number](https://shopify.dev/docs/api/liquid/basics#number) * The total number of iterations in the loop. * parentloop [forloop](https://shopify.dev/docs/api/liquid/objects/forloop) * The parent `forloop` object. If the current `for` loop isn't nested inside another `for` loop, then `nil` is returned. ![](https://shopify.dev/images/icons/32/lightbulbscroll.png)![](https://shopify.dev/images/icons/32/lightbulbscroll-dark.png)ExampleUse the `parentloop` property ```liquid {% for i in (1..3) -%} {% for j in (1..3) -%} {{ forloop.parentloop.index }} - {{ forloop.index }} {%- endfor %} {%- endfor %} ``` ##### Code ``` {% for i in (1..3) -%} {% for j in (1..3) -%} {{ forloop.parentloop.index }} - {{ forloop.index }} {%- endfor %} {%- endfor %} ``` ## Output ```html 1 - 1 1 - 2 1 - 3 2 - 1 2 - 2 2 - 3 3 - 1 3 - 2 3 - 3 ``` * rindex [number](https://shopify.dev/docs/api/liquid/basics#number) * The 1-based index of the current iteration, in reverse order. * rindex0 [number](https://shopify.dev/docs/api/liquid/basics#number) * The 0-based index of the current iteration, in reverse order. ```json { "first": true, "index": 1, "index0": 0, "last": false, "length": 4, "rindex": 3 } ``` ##### Example ``` { "first": true, "index": 1, "index0": 0, "last": false, "length": 4, "rindex": 3 } ``` ### Use the `forloop` object ```liquid {% for page in pages -%} {%- if forloop.length > 0 -%} {{ page.title }}{% unless forloop.last %}, {% endunless -%} {%- endif -%} {% endfor %} ``` ##### Code ``` {% for page in pages -%} {%- if forloop.length > 0 -%} {{ page.title }}{% unless forloop.last %}, {% endunless -%} {%- endif -%} {% endfor %} ``` ## Output ```html About us, Contact, Potion dosages ```