Responsible Shopify engineering starts with ownership, boundaries and validation.
Building a Product Recommender in Shopify Liquid
A Liquid-based product recommender that doesn't need an app, doesn't slow the PDP, and uses real signals, order history, current cart, and product metafields.
Published
Reading brief
What you will get from this guide
A Liquid-based product recommender that doesn't need an app, doesn't slow the PDP, and uses real signals, order history, current cart, and product metafields.
What this guide covers
Available storefront signals, fallback logic, caching, Liquid constraints, measurement, and when to graduate to an app or service.
Who this is for
Shopify developers and technical operators who need a fast merchandising pattern without pretending it is a full personalization system.
Building a Personalized Product Recommender in Shopify Liquid
Shopify's built-in recommendations.products is a good baseline. Apps that promise "AI personalization" usually deliver slow scripts and ugly carousels. The middle ground, a Liquid + Section Rendering API recommender powered by your own signals, is where the lift lives.
Signals you actually have
- Current cart contents.
- Customer order history (
customer.orders). - Product metafields (occasion, material, line, complement_to).
- Browsing session (via cookie or local storage).
Work with us
Need help applying this to your store?
Shugert has shipped 30+ Shopify builds and migrations since 2016. Book a working session and we'll map the next concrete step for your store.
The architecture
- PDP renders a placeholder section.
- Section Rendering API fetches a personalized section async, passing the customer ID and current product.
- The section uses Liquid logic against metafields and order history to pick complements.
- Cache aggressively at the section level.
{%- comment -%} sections/recommended-for-you.liquid {%- endcomment -%}
{%- liquid
assign current = product
assign suggestions = ''
if customer
for order in customer.orders limit: 5
for line in order.line_items
assign suggestions = suggestions | append: line.product.id | append: ','
endfor
endfor
endif
assign complement_ids = current.metafields.custom.complement_products.value
-%}Why this beats most apps
- Native speed. Renders inside your existing critical path or async via Section Rendering API.
- No black box. You control the rules, so merchandising can adjust them.
- No monthly fee. It's your code.
- AI-ready. Add an LLM call server-side later if you want, same architecture.
When to use a real personalization platform
If you're running 1000+ orders/day and have rich first-party data, platforms like Rebuy, Nosto, or Klaviyo's on-site personalization can outperform pure Liquid. Below that, Liquid wins on ROI.
We build personalization, PDP, and merchandising features on Shopify and Shopify Plus. Get a quote.
As of early 2026, the strategy for building product recommenders on Shopify has shifted from basic Liquid loops to a hybrid model utilizing Shopify Functions and the Search & Discovery logic. While Liquid remains the primary templating language for rendering these components, the retirement of Shopify Scripts on August 28, 2025, forced a transition toward Shopify Functions for backend logic. This shift allows developers to inject recommendation rules directly into the cart and checkout engines, ensuring that personalized bundles or "frequently bought together" logic remains consistent across the entire buyer journey.
The rise of agentic commerce and the Model Context Protocol (MCP) in 2026 has further evolved how signals are processed. Brands are increasingly moving away from third-party JavaScript carousels that damage Core Web Vitals, opting instead for server-side logic executed via Hydrogen or Oxygen for headless builds, or the Section Rendering API for Liquid themes. By leveraging the Search & Discovery API’s 'related products' endpoint alongside custom metafields, merchants can now achieve high-intent personalization without the latency overhead typically associated with legacy recommendation apps. This architectural choice is critical for brands chasing the Q1 2026 GMV milestones, where conversion rate optimization (CRO) hinges on millisecond-fast page loads.
Frequently asked questions
Why is a Liquid-based recommender faster than a third-party app?
Liquid executes on Shopify's servers before the page is sent to the browser. Unlike app-based recommenders that load via JavaScript after the page is visible, Liquid-rendered recommendations prevent 'layout shift' and ensure the content is indexable by search engines. By using the Section Rendering API, you can fetch these recommendations asynchronously to keep the initial page load fast while still serving pure HTML.
How do I combine Shopify's native AI recommendations with my own Liquid logic?
As of 2025-2026, Shopify recommends using the 'Related Products' logic within the Search & Discovery app to seed the initial data, then filtering that data in Liquid using logic-based metafields (e.g., 'exclude_if_out_of_stock' or 'match_by_material'). This combines Shopify's machine learning with your specific merchandising rules.
Does the deprecation of Shopify Scripts affect Liquid recommenders?
Shopify Scripts was officially deprecated on August 28, 2025. For modern recommenders that involve discounting (e.g., 'Buy this recommendation and get 10% off'), you must now use Shopify Functions. A Liquid recommender can identify the product to show, but the Function handles the logic of applying the discount once that product is added to the cart.
Can Liquid access a customer's full purchase history for personalization?
To personalize for returning customers, use the customer.orders object to scan previous purchases. You can look for specific tags or product types and then use Liquid's where filter to suggest complementary items. For example, if a customer previously bought a 'Camera Body,' your Liquid logic can prioritize 'Lenses' in the recommendation section.
Further reading
Related Shugert resources
- The full Shopify development stack, when to use Liquid vs. Functions vs. apps
- How personalization fits into a broader CRO strategy
- Need this built for your store?
Additional references
<!-- phase-3-priority-content:liquid-recommender -->Liquid product recommender implementation contract
A Liquid recommender is a deterministic merchandising rule. It is useful when the store needs a fast, explainable fallback and does not require real-time personalization.
| Contract | Minimum decision |
|---|---|
| Candidate source | Collection, product metafield, metaobject, or manually curated list |
| Exclusions | Current product, unavailable items, restricted markets, and duplicate variants |
| Ranking | Explicit merchant order or a documented deterministic rule |
| Fallback | A safe collection or empty state when fewer candidates qualify |
| Performance | Bound loops, image loading, and rendered card count |
| Measurement | Impression, click, add-to-cart, and revenue-assist definitions |
When is Liquid enough?
Use Liquid when candidate data already exists at render time, the rule is stable, and explainability matters more than per-session learning. Keep the output small and predictable.
When should the store graduate to an app or service?
Move beyond Liquid when ranking depends on customer history, inventory velocity, real-time behavior, experimentation, cross-session identity, or a large candidate set. Require data contracts, consent review, latency budgets, monitoring, and fallback behavior before production use.
For extension-surface choices, use the Shopify development guide. For the broader build-or-buy decision, use the custom development vs apps scorecard.
Verified primary sources
Documentation used to validate this guide
Platform capabilities, dates, and technical recommendations should be checked against first-party documentation. These links leave Shugert and open the original source.
Recommended path
From learning to an executable decision.
This resource belongs to the Custom Build or Replatform journey. Use the pillar guide for the complete framework, review the relevant capability, and request a scope when the issue requires implementation.
Read the pillar guide
Custom build and replatform guide
Review the relevant capability
Shopify Development
Custom Build or Replatform
A bounded project for themes, migrations, apps, integrations, B2B, and architecture changes.
Keep reading
Related resources
Continue with a guide from the same operating system, not a generic recommendation.