How can I sort collection items by publish date, not created date?

Topic summary

Main issue: Sort collection products by publish date (published_at) instead of created date in Shopify (Debut theme). Users want newest-by-publish-date ordering across collections.

What works for many: Use Liquid to sort collection.products by published_at and loop over a reassigned array (e.g., collection_products). Some tie it to the sort_by parameter (created-ascending/descending) to reuse Shopify’s UI options. product.published_at is the publish timestamp; created_at can’t be changed. Draft → publish can reset published_at; scheduling sets future publish times.

Key limitations and pitfalls:

  • Front-end sorting conflicts with pagination. Shopify paginates collection.products server-side, so sorting often affects only items within a page, causing wrong order and blank grid gaps. Arrays like reassigned lists can’t be paginated. A suggested workaround is wrapping with paginate all_products by 50, but it only helps when total products < 1000 and Shopify now limits loops to ~50 per page.
  • Large catalogs (>1000) and pagination: no reliable theme-only solution; removing pagination can work but may hurt performance.
  • Metafield-based date sorting didn’t work for some.

Alternatives/outcomes:

  • Apps (e.g., Advanced Collections) sort on the backend and avoid pagination issues.
  • Some use Mechanic to automate ordering.

Status: No native Shopify option; partial code workarounds exist, but large catalogs/pagination remain unresolved.

Summarized with AI on December 13. AI used: gpt-5.

Hello, this seems to work fine for native properties, but using a product metafield doesn’t seem to work on my side, any thoughts? I tried adding a Date metafield, so the sort string is metafields.custom.published_date but it seems to not change anything even with a couple of products having values for said metafield.

Oh also you have a rogue space in the created-ascending sort by if check.