Shopify Related Products and Collection Links: Liquid Snippets
Shopify’s product recommendations are filled in by JavaScript after the page loads, from a path the default robots.txt disallows. Shoppers see them; crawlers that read the page source don’t. This free pack of Liquid snippets adds related products and other internal links that are printed on the server instead, so they’re in the HTML every crawler gets, with no app to install.
Who it’s for
Store owners, SEOs and developers on Shopify who want related-product links they control, and who are comfortable pasting a file into the theme code editor. Each snippet takes one line to place, and a Custom Liquid block in the theme editor is enough, so you don’t need to edit your templates.
How to use it
- Duplicate your theme and make every change on the copy. Undo is switching back.
- Create the metafield definitions the snippets read, in Settings › Metafields and metaobjects: related products (a list of products), related collections, a primary collection and, for blog posts, featured products.
- Add the snippet files in Edit code, and the section if you want a ready-made “more from this collection” block.
- Place each one with a single render line, for example
{% render 'mlfs-related-products', product: product, limit: 4 %}, in a Custom Liquid block. - Pick the related products on a few products, then preview one with the metafield set and one without.
- Open View page source (not Inspect) and search for one of the new link targets. If it’s there, crawlers get it.
What you get
- Related products and related collections from reference metafields, with a limit and an option to skip sold-out items
- “Shop more in” links from a product back to its collections, excluding all, frontpage and any handles you list
- Brand and category links that point at real collections instead of the automatic
/collections/vendors?q=pages, falling back to plain text - “Shop the products in this post” for blog articles
- A theme section, More from this collection, with a metafield override for the collection it uses
- Install steps, styling notes, the sample data and the rendered output of every test case
Every snippet links the canonical /products/handle URL, never links a page to itself, skips empty collections and prints nothing when there’s nothing to link, so you never get an empty heading.
Limits
I rendered every snippet with LiquidJS on sample data shaped like Shopify’s product, collection, article and metafield objects: 15 test cases, all passing. LiquidJS is a different engine from Shopify’s, and I haven’t run the snippets on a live store yet, which is why the steps start with a duplicate theme. Filling metafields for a large catalogue is still a job: the bulk editor in the same repository folder handles body links, and the course covers picking the related items with embeddings.
Read the step-by-step guide, Shopify related products with metafields, no app, and learn how to choose which pages should link to each other in AI-powered Internal Linking Audit and Automation.
What’s included
- Related products and related collections from reference metafields, printed as plain links in the page source
- "Shop more in" collection links, a "more from this collection" section and "shop the products in this post" for articles
- Brand and category links to real collections instead of /collections/vendors?q= pages
- Canonical /products/ URLs, no self-links, no empty headings, one render line to place each snippet
- 15 test cases rendered with LiquidJS on sample data, with the output in the repo
Where this resource is used on MLforSEO
Walkthroughs on the blog
More internal linking resources
- Coding Script or NotebookLink Blocks for WordPress: Related Posts, Topic Cards, Siblings and Mentions
- Coding Script or NotebookLink Menu to Linking Rules: Python Script for Auto-linking Plugins
- ChecklistBefore You Build: A Checklist for Internal Linking Tools
- Coding Script or NotebookInternal Linking QA and Holdout Group Notebook
- Visualization TemplateInternal Linking Impact Dashboard (Data Studio Template) with Setup Guide
- Coding Script or NotebookInternal Link Menu Notebook: Priority Score and Versioned Recommendations
See all 26 internal linking resources →See all 73 coding script or notebook resources →
