Parent Values#
Inside a nested loop, plain values belong to the inner result. Use parent to read from the outer result.
{{ query:pages }} <section> <h2>{{ title }}</h2> {{ query:posts }} <article> <p>Page: {{ parent.title }}</p> <h3>{{ title }}</h3> </article> {{ /query:posts }} </section>{{ /query:pages }}Inside query:posts, {{ title }} is the post title. {{ parent.title }} is the page title from the outer loop.
More Than One Level#
Use parent.parent when you need to go one more level up.
{{ query:pages }} {{ query:posts }} {{ query:project }} <p>{{ parent.parent.title }} / {{ parent.title }} / {{ title }}</p> {{ /query:project }} {{ /query:posts }}{{ /query:pages }}Keep deeply nested loops rare. They are useful, but usually harder to scan than a small partial.