The pages global Liquid object is now iterable
Themes
Effective May 21, 2021
You can now iterate through the global Liquid pages
object, instead of only being able to directly reference known pages through their handle. This allows you to access a paginated pages listing of up to 50 items at a time and produce HTML that is conditional to the page data that is available.
You can return properties for a specific page using {{ pages.pagename.propertyname }}
:
<h1>{{ pages.about.title }}</h1>
<p>{{ pages.about.author }} says...</p>
<div>{{ pages.about.content }}</div>
You can also interate through up to 50 pages at a time with pagination:
<ul>
{%- paginate pages by 50 \-%}
{%- for p in pages -%}
<li>{{p.title}}</li>
{%- endfor -%}
{{ paginate | default\_pagination: next: 'Older', previous: 'Newer' }}
{%- endpaginate \-%}
</ul>