Skip to content

Shopify Related Products with Metafields: No App Needed

By Lazarina Stoy · 10 min read
Shopify Related Products with Metafields: No App Needed: illustration of pages connected by internal links. An MLforSEO guide by Lazarina Stoy.

Every Shopify theme seems to come with a “You may also like” row under the product. It looks like the perfect internal linking block: four or so related products, on every product page, with no work from you. For shoppers it often is. For search engines, it mostly isn’t there.

In this tutorial I’ll show why, and how to build related-product links that every crawler gets, using a product-reference metafield and a few lines of Liquid. No app, no monthly fee, and nothing that disappears if you uninstall something. The same approach handles related collections, links back to a product’s collections, brand links and “shop the products in this post” on blog articles.

Free code

Shopify related products and collection links: Liquid snippets: five snippets and a theme section that print related products, related collections and brand links as plain, crawlable links.

On this page
  1. Why not just use Shopify’s product recommendations?
  2. What metafields are, and why reference metafields fit
  3. How the metafield method works
  4. Step by step: related products from a metafield
  5. Four more no-app links from the same pack
  6. What I tested, and what I didn’t
  7. Filling the metafields for a whole catalogue
  8. Things to watch
  9. Where the course comes in
  10. Frequently asked questions

Why not just use Shopify’s product recommendations?

Side-by-side of Shopify's native recommendations, loaded by JavaScript from a robots.txt-disallowed path, and a metafield block rendered in the page source
Native recommendations are for shoppers; a server-rendered metafield block is the one crawlers can follow.

Shopify’s related products section works like this, according to its own developer docs: the section renders with an empty recommendations object, then JavaScript fetches the filled-in section from the Product Recommendations API at /recommendations/products and swaps it in. It supports two intents, related (the default) and complementary, and the docs suggest limiting it to four products per page so only the most relevant appear.

The links in that row only exist after JavaScript runs. On the live stores’ default robots.txt files I checked on 5 December 2026, /recommendations/products is disallowed, and Google’s JavaScript SEO basics say Googlebot doesn’t request disallowed URLs. My reading: Google never sees those product links. Crawlers that don’t render JavaScript at all, which includes most AI crawlers, never had a chance. If you’re deciding which of those to let in, I covered that in which AI crawlers to block.

Two more things from Shopify’s Search & Discovery help page: you can add your own related and complementary picks (up to 10 of each), but you can’t edit the generated ones, and the generated recommendations for a product “change frequently”. Fine for merchandising. Not what I want for a stable internal link structure.

So I keep the recommendations section for shoppers and add a second, server-rendered block for links. That’s what the rest of this post builds.

What metafields are, and why reference metafields fit

Metafields are custom fields you add to products, collections, blog posts and other parts of Shopify. Most hold text or numbers, but some types hold references to other objects: a product, a collection, a page. And a metafield can be a list of those references.

That last part is what makes them perfect for related links. Shopify’s Liquid reference for metafields says a product_reference metafield returns a full product object, and a list returns an array of them. So in the theme you get each related product’s title and URL directly, and if you rename a product’s handle, the reference still points to the right product.

One rule to know before you start: Liquid can read metafields but can’t create them. You define the field in the admin first.

How the metafield method works

Flow from a product-reference list metafield set in the Shopify admin, through a Liquid snippet in the theme, to crawlable related-product links in the HTML the server sends
The metafield method: pick related products once in the admin, and a short Liquid snippet prints them as real links on every product page.

Three pieces, each with one job:

  1. A metafield definition called custom.related_products, of type Product, set to hold a list of values.
  2. An editor picks the products for each product page in the admin, the same way they’d fill in any other field.
  3. A Liquid snippet in the theme loops through the list and prints each product as an ordinary <a href>, on the server, before the page is sent.

Because the links are in the HTML from the start, they meet Google’s crawlable links requirements without any rendering, and they’re in the source for every other crawler too.

1. Duplicate your theme

Online Store › Themes › your theme › ⋯ › Duplicate. Do everything on the copy, preview it, then publish. If something looks wrong later, you switch back.

2. Create the metafield definition

Go to Settings › Metafields and metaobjects › Products (or the Metafields section at the bottom of any product) and click Add definition. Name it “Related products”, check that the namespace and key read custom.related_products, choose the type Product, switch One value to List of values, and save.

3. Add the snippet

In the theme copy, open ⋯ › Edit code, click Add a new snippet under snippets, call it mlfs-related-products, and paste the file from the snippets folder on GitHub. The core of it is this loop:

{%- for item in product.metafields.custom.related_products.value -%}
  {%- if item == blank or item.id == product.id -%}{%- continue -%}{%- endif -%}
  {%- if shown >= max -%}{%- break -%}{%- endif -%}
  <li><a href="{{ item.url }}">{{ item.title | escape }}</a></li>
  {%- assign shown = shown | plus: 1 -%}
{%- endfor -%}

Around that loop, the snippet sets a limit (four by default), never links a product to itself, can skip sold-out products if you want, and prints nothing at all when the list is empty, so a product without picks never shows an empty heading.

4. Place it

In the theme editor, open your product template and add a Custom Liquid block or section where you want the links. Shopify allows standard Liquid tags in those blocks, so one line does it:

{% render 'mlfs-related-products', product: product, limit: 4, heading: 'Pairs well with' %}

5. Pick the products

Open a product, scroll to Metafields, and choose the related products. Start with your best sellers and your most-visited products: they’re the pages where links are seen most.

6. Check the page source

Preview a product with picks and one without. On the first, choose View page source (not Inspect) and search for one of the related product URLs. It should be there, as plain HTML. Here’s what the snippet printed in my test, for a sencha product with seven picks, one of them itself:

<nav class="mlfs-links mlfs-related-products" aria-label="Related products">
  <h2 class="mlfs-links__heading">Related products</h2>
  <ul class="mlfs-links__list">
    <li class="mlfs-links__item"><a href="/products/toasted-genmaicha">Toasted Genmaicha</a></li>
    <li class="mlfs-links__item"><a href="/products/shade-grown-gyokuro">Shade-Grown Gyokuro</a></li>
    <li class="mlfs-links__item"><a href="/products/ceremonial-matcha">Ceremonial Matcha</a></li>
    <li class="mlfs-links__item"><a href="/products/roasted-hojicha">Roasted Hojicha</a></li>
  </ul>
</nav>

Four links, the limit, and the product’s own page left out.

The same idea covers the other links a store usually lacks. All of these are in the free snippet pack:

  • Related collections from a collection-reference list metafield, on product or collection pages. Empty collections are skipped, and a collection page never links to itself.
  • Links back to the product’s collections, read straight from product.collections, with a list of handles to exclude. LOGEIX’s Shopify automated linking guide suggests this pattern and says to add exclusion rules; I’d exclude all, frontpage and any sale or seasonal collection.
  • “More from this collection”, a theme section that links the product’s main collection and a few other products in it. An editor can override the collection per product with a single collection-reference metafield, so the product’s first collection doesn’t always win.
  • “Shop the products in this post” for blog articles, from a product list metafield on the article.

Replacing vendor and type links

If your theme links the vendor or product type with link_to_vendor or link_to_type, those links go to automatic pages like /collections/vendors?q=Hilltop%20Estates, which can’t carry a description or sit in your category structure. Regan McGregor’s Shopify internal linking guide makes the same point. The snippet looks for a real collection with the vendor’s handle and links that instead:

{%- assign v_handle = product.vendor | handleize -%}
{%- assign v_collection = collections[v_handle] -%}
{% if v_collection.id and v_collection.all_products_count > 0 %}
  <a href="{{ v_collection.url }}">{{ product.vendor | escape }}</a>
{% else %}
  {{ product.vendor | escape }}
{% endif %}

With no matching collection, the brand name prints as plain text. No link beats a link to a page you can’t optimise.

What I tested, and what I didn’t

I rendered every snippet and the section with LiquidJS, a JavaScript implementation of Liquid, against sample data shaped like Shopify’s product, collection, article and metafield objects. The test suite has 15 cases: the links that must appear, the ones that must not (the product itself, excluded and empty collections, any ?q= URL), the number of links, and that empty data prints nothing. All 15 pass, and the HTML from each case is in the repository.

That proves the syntax and the logic. It doesn’t prove identical behaviour inside a Shopify theme, because LiquidJS is a different engine and I stubbed the Shopify-only parts. I haven’t run the snippets on a live store yet, which is exactly why every step above starts with a duplicate theme.

Filling the metafields for a whole catalogue

Picking related products by hand is fine for your top 50 products. For more, you have two routes.

The first is to generate candidates. A similarity-based approach, such as the embeddings in the internal link audit and topic clustering notebook, can suggest the nearest products for each one. Someone should still review the list: related products are a merchandising decision as much as an SEO one.

The second is to write the approved picks in bulk through the Admin API with the metafieldsSet mutation, which sets up to 25 metafields per call. Treat it like any bulk write: dry run first, keep the old values, and write in small batches. For links inside product descriptions and blog posts, the free Shopify bulk internal-link editor does that routine for you.

Things to watch

  • Sold-out products. I keep them linked by default, since their pages usually still exist and rank. Set skip_sold_out: true if your store hides them.
  • Too many links. Four to six related products is plenty. A block that links twenty products tells nobody what matters.
  • The canonical URL. The snippets link /products/handle, never /collections/x/products/handle, which is a duplicate of the same page.
  • Measuring it. Crawl before and after, and count inlinks per product. The blog architecture audit notebook shows the click-depth side of the same question.
  • Where it fits. Related links are one layer of a structure. Plan the collections first: a search-intent-first architecture is a good place to start, and blog and site architecture in the AI search era covers how guides and hubs connect.

Where the course comes in

Metafield blocks solve the “where” for related links. The “which” is harder: which products and collections should link to each other, which anchors to use, which links to approve, and whether any of it moved traffic. The course AI-powered Internal Linking Audit and Automation, led by Sam Torres, works through that with embeddings, a reviewed link menu and a measurement plan. My guest module covers shipping the approved links on WordPress, headless sites, Shopify and Webflow, including this theme route and the Admin API route end to end. If you’re weighing up other ways to automate the work, I compared them in 10 ways to automate internal linking with AI.

For the wider picture of where links live on a store and which ones crawlers see, read the companion guide: Shopify internal linking: where links live and how to add them. The 10-location checklist goes with it.

Free code

Shopify related products and collection links: Liquid snippets: related products, related collections, collection back-links, brand links and “shop this post”, printed as crawlable links, with install steps.

Frequently asked questions

How do I show related products on Shopify without an app?

Create a product metafield of type Product with a list of values, pick the related products on each product, and print them in your theme with a short Liquid loop over product.metafields.custom.related_products.value. The links are rendered on the server, so they’re crawlable.

Can I use metafields for related products?

Yes. A product-reference list metafield is made for it: in Liquid it returns the product objects themselves, with titles and URLs, and the references survive handle changes.

Are Shopify product recommendations good for SEO?

They’re good for shoppers. As links they do little, because the section loads with JavaScript from /recommendations/products, which the default robots.txt disallows. Pair them with a server-rendered block.

What’s the difference between related and complementary products on Shopify?

Related products are similar items, generated by Shopify and optionally added to by you. Complementary products are items that go with the product (“pair it with”), and you choose them yourself in the Search & Discovery app. Showing complementary products needs a theme that supports them.

How many related products should I show?

Shopify’s docs suggest four per product page for recommendations, and I’d use the same for a metafield block: enough to be useful, few enough that each link means something.

MLforSEO Academy

Pick your learning path

Start with the course that goes deepest on this article, then more courses taught by Lazarina Stoy, most relevant first.

Recommended with this article

AI-powered Internal Linking Audit and Automation

by Sam Torres with Lazarina Stoy

Audit how your site links to itself, find the pages and entities your links leave out, and plan and automate the fixes with AI at scale.

View course · €350 →

Introduction to Machine Learning for SEO

by Lazarina Stoy

Go from zero to running your first ML workflows for SEO: classification, clustering, entity extraction, fuzzy matching and content transformation.

View course · €250 →

Semantic AI-powered SEO Keyword Research

by Lazarina Stoy with Beatrice Gamba

Build a semantic keyword universe and an automated content-brief workflow, from query understanding through SERP analysis to delivery.

View course · €400 →

AI Search & LLMs: Entity SEO and Knowledge Graph Strategies for Brands

by Beatrice Gamba with Lazarina Stoy

Win in both traditional Google and LLM-driven search by mastering entities, brand recognition, and knowledge graph integration.

View course · €200 →

The AI-powered Entity Audit

by Lazarina Stoy

A complete, repeatable entity audit you can run on any site. Built on the 5Cs of entity representation and demonstrated end to end on a real, unedited site.

View course · €150 →
Bundle & save up to €200 →See all 6 courses →Already an Academy member? Use Community30 for 30% off your next course or bundle.