---
title: 'Twig loop on nested list'
url: 'https://getgrav.org/forum/themes-styling/twig-loop-on-nested-list-t6734'
markdown: 'https://getgrav.org/forum/themes-styling/twig-loop-on-nested-list-t6734.md'
date: '2026-06-21'
description: 'Hey everyone how would I run a loop on a nested list? For example, lets say I have a parent categories for music genre like "Rock & Roll" , "Country", etc...'
---

[Themes & Styling](https://getgrav.org/forum/themes-styling)

#  Twig loop on nested list 

  Started by Dan Hart 9 years ago · 2 replies · 1303 views    

 [9 years ago](https://getgrav.org/forum/themes-styling/twig-loop-on-nested-list-t6734#post-20086 "Permalink") 

Hey everyone how would I run a loop on a nested list? For example, lets say I have a parent categories for music genre like "Rock & Roll" , "Country", etc... and then underneath each of those would be artist?

 [9 years ago](https://getgrav.org/forum/themes-styling/twig-loop-on-nested-list-t6734#post-20094 "Permalink") 

Nest the loops:

```twig
{% for data as genre %}
  {% for genre as subgenre %}
    {% for subgrense as artist %}
      {{ artist.name }}
    {% endfor %}
  {% endfor %}
{% endfor %}
```

 👍 1 

 [9 years ago](https://getgrav.org/forum/themes-styling/twig-loop-on-nested-list-t6734#post-20095 "Permalink") 

Thanks OleVik!

When I first started to work through this I only had 2 "for" loops but it turned out I needed 3 like what you have here. Worked like a charm, thanks!

[Log in](https://getgrav.org/login?return=%2Fforum%2Fthemes-styling%2Ftwig-loop-on-nested-list-t6734) to reply.

###  Suggested topics

 | Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| [Grav2 with Quark2 – All pages in the hamburger-menu of a one-pager](https://getgrav.org/forum/themes-styling/grav2-with-quark2-all-pages-in-the-hamburger-menu-of-a-one-pager-t9485)    [Themes & Styling](https://getgrav.org/forum/themes-styling) · by AH, 2 weeks ago |  | 1 | 199 | [9 hours ago](https://getgrav.org/forum/themes-styling/grav2-with-quark2-all-pages-in-the-hamburger-menu-of-a-one-pager-t9485 "by AH") |
| [\[quark\] mobile menu as the modular page menu](https://getgrav.org/forum/themes-styling/quark-mobile-menu-as-the-modular-page-menu-t1132)    [Themes & Styling](https://getgrav.org/forum/themes-styling) · by Bruno, 4 years ago |  | 6 | 1350 | [10 hours ago](https://getgrav.org/forum/themes-styling/quark-mobile-menu-as-the-modular-page-menu-t1132 "by AH") |
| [Modular Page Background Image Display](https://getgrav.org/forum/themes-styling/modular-page-background-image-display-t9486)    [Themes & Styling](https://getgrav.org/forum/themes-styling) · by TomW, 2 weeks ago |  | 2 | 203 | [2 days ago](https://getgrav.org/forum/themes-styling/modular-page-background-image-display-t9486 "by TomW") |
| [Inheriting a Theme does not quite work correctly](https://getgrav.org/forum/themes-styling/inheriting-a-theme-does-not-quite-work-correctly-t9501)    [Themes & Styling](https://getgrav.org/forum/themes-styling) · by themetman, 3 days ago |  | 0 | 56 | [3 days ago](https://getgrav.org/forum/themes-styling/inheriting-a-theme-does-not-quite-work-correctly-t9501 "by themetman") |
| [Is it a way to get the "content - summary" in a twig template ?](https://getgrav.org/forum/themes-styling/is-it-a-way-to-get-the-content-summary-in-a-twig-template-t9431)    [Themes & Styling](https://getgrav.org/forum/themes-styling) · by FrViPofm, 2 months ago |  | 4 | 668 | [1 month ago](https://getgrav.org/forum/themes-styling/is-it-a-way-to-get-the-content-summary-in-a-twig-template-t9431 "by Paul Hibbitts") |
