← InboxTheme development, Module 1, lesson 13, 10 min
List the five most recent blog articles in the footer How this works
Shopify hands you an array of articles. You want one <li> per article, capped at five.
{% for article in blogs.journal.articles limit: 5 %}
< li > {{ article.title }} </ li >
{% endfor %} article, loop variable. Singular. You pick the name. blogs.journal.articles, Shopify's array. Already sorted newest-first. limit: 5, stops after five iterations. limit: is part of the {% for %} tag, not a filter. {% for ... | limit: 5 %} is the AI-shaped mistake; it errors.
Always cap unbounded arrays. A footer that loops 200 articles on every page blows up page weight. Why this matters in production ▾ Footer 'recent posts' lists, 'related products' sections, navigation dropdowns with featured items. Anywhere you need a capped subset of an array, `{% for %}` with `limit:` is the pattern.