Rel="next" / rel="prev" missing from content_for_header when another paginate runs before the collection's

Short description of issue

On collection pages, the rel="next" / rel="prev" link tags injected in content_for_header disappear when another paginate tag (e.g. on a metaobject list) runs before the collection’s paginate. Moving it after the collection’s paginate restores them.

Reproduction steps

  1. Use a collection with more than one page of products, paginated in the main collection section:
{%- paginate collection.products by 24 -%}
  ...
{%- endpaginate -%}
  1. Check the page source: <link rel="next" href="/collections/xxx?page=2"> is present in content_for_header. :white_check_mark:

  2. In the same section, add a paginate on a metaobject list BEFORE the collection paginate:

{%- paginate metaobjects.stores.values by metaobjects.stores.values.count -%}
  {%- assign store = metaobjects.stores.values | find: 'some_field', filter_value.label -%}
{%- endpaginate -%}
  1. Reload: <link rel="next"> / <link rel="prev"> are no longer injected. :cross_mark:

  2. Move that same paginate block AFTER the collection’s {% endpaginate %}: the tags are injected again. :white_check_mark:

Additional info

Using paginate on metaobjects is the standard workaround to access more than 50 entries in Liquid. When it runs before the product grid, the collection’s pagination link tags silently disappear.

It looks like content_for_header relies on the first paginate executed during the render, not on the one wrapping the template’s main resource.

We only tested this on collections, but the same behavior probably applies to other paginated resources (blog.articles, search.results).

Expected: the pagination link tags should reflect the paginate of the template’s main resource (collection.products on a collection page), regardless of other paginate tags executed before it.

Questions:

  • Is this the intended behavior? If so, could it be documented in the paginate (Liquid tags: paginate) or content_for_header (Liquid objects: content_for_header) docs?
  • Is there a recommended way to access more than 50 metaobject entries without affecting the pagination tags?

What type of topic is this

Bug report

Hi @MaxX, thanks for the reproduction steps. I was able to reproduce this in a test shop myself.

I don’t believe this is intended behavior, at least when metaobjects are involved. Let me double-check and confirm, and I’ll get back to you.

Hi @Paige-Shopify, any update on this one? Thanks!

Hi @MaxX The team has confirmed this is expected behavior. I’m just waiting on confirmation on whether this workaround I put together with is officially supported. Essentially it follows this structure:

{% capture collection_content %}
// collection content including collection pagination here
{% endcapture %}

{% paginate metaobjects.product_sets.values by metaobjects.produict_sets.values.count %}
 // rest of metaobject here
{% endpaginate %}

{{ collection_ content }}

Hi @Paige-Shopify,

Thanks for looking into this and for sharing the workaround.

Unfortunately it doesn’t really work for us in practice. Our themes sometimes use paginate on metaobjects outside the collection section, in snippets rendered from the layout and from section groups. Depending on the template, these can run before the template’s main paginate (collection.products, search.results or blog.articles). Wrapping the main content in a capture doesn’t help when the other paginate lives in a different file that’s rendered earlier, and we can’t always control that order.

Because nothing errors or shows up visually (the rel="prev" / rel="next" tags just disappear from content_for_header), I suspect a lot of stores have this problem without knowing it. Paginating a metaobject list just to get past Liquid’s 50-item limit is a common pattern, and a single instance of it running before the main paginate is enough to lose the tags.

So a fix on the platform side would be much better and very welcome. For example, content_for_header could use the pagination of the template’s main resource (collection.products, search.results, blog.articles) rather than whichever paginate runs first.

Could you let us know whether this is something the team would consider?

Thanks!

Hi @MaxX, thanks for explaining how your themes use metaobject pagination. I can see why the workaround isn’t practical when those snippets are rendered earlier in the layout or a section group.

The team is open to improving how this works in the future, but they aren’t able to take it on in the near term. If they address it in the future, I’ll let you know here.

Thanks @Paige-Shopify, we appreciate the honest answer.

That said, it’s a bit disappointing to see this deprioritized: the issue is silent (nothing breaks visually, the tags just disappear from the head), so most merchants will never notice it, and it affects SEO on key templates like collections and search. Since there’s no clean theme-side workaround when the pagination lives in a section group, we really think this belongs on the platform side. We’ll follow this thread for updates.

Worth noting on the SEO side: Google said back in 2019 they don’t use rel=next/prev for indexing or ranking at all, Googlebot just follows the crawlable links instead. Bing still treats it as a discovery hint though, so I’d call this annoying and worth fixing but probably smaller SEO exposure than it looks for Google specifically.