Your product page template code lives inside your theme files, reachable at Online Store > Themes > … (next to your theme) > Edit code. On modern Online Store 2.0 themes the layout is a JSON template (templates/product.json) that points at a Liquid section (sections/main-product.liquid); older themes carry one combined templates/product.liquid file. Duplicate the theme before you touch either one — code edits on a live theme ship instantly, and there is no undo button.

If you already run a store, you're not editing product page template code to learn Liquid. You're editing it to add a size guide, a shipping-time badge, a bundle block, or urgency copy to the pages that carry your ad spend — and you want to do it without breaking checkout at 2pm on a Tuesday.

The top guides for this keyword stop at "here's the Edit code button." This one goes further: the exact files, how to create a custom template and assign it to one product, the limits that quietly cap what you can build, and — the part every other article skips — how to decide which pages are even worth the hours.

Where the product page template code actually lives

Open the admin, go to Online Store > Themes, click the … (or Actions) menu beside your live theme, and choose Edit code. That opens the file tree for the whole theme.

Which file holds your product page depends on the theme's age. This is the single most common source of confusion, because the two layouts look nothing alike.

JSON template vs the Liquid section

On an Online Store 2.0 theme (Dawn and nearly every theme sold since), the file at templates/product.json is not markup at all — it's a small configuration file that lists which sections render and in what order. The actual HTML, Liquid, and logic live in sections/main-product.liquid, where you'll find objects like {{ product.title }}, {{ product.price }}, and the variant picker.

On a legacy "vintage" theme, there's a single templates/product.liquid that holds the markup directly, with no JSON layer in front of it. If you open templates/product.liquid and see only a block of JSON, you're on a 2.0 theme and need to edit the section file instead.

The practical rule: on a 2.0 theme, structural layout changes happen in the JSON (and in the drag-and-drop theme editor, which writes to that JSON for you), while real markup and logic changes happen in sections/main-product.liquid. Snippets you reuse across pages live in the snippets/ folder and get pulled in with a render tag.

Open the code editor without breaking your live store

Code you save in Edit code is live the instant you hit save. There's no staging copy and no version history you can roll back to from the admin, so the first move on any operating store is always the same: duplicate the theme.

From Online Store > Themes, use the … menu on your live theme and choose Duplicate. Edit the copy, preview it, and only publish once it's verified. This is the same discipline you'd use before a bulk catalog change — the logic behind always keeping a pre-import export when you run a product CSV update is identical: a destructive action with no undo needs a known-good restore point.

Preview the duplicate on both desktop and a phone before publishing. Theme code that looks fine at full width routinely breaks the variant picker or the Add to cart button on mobile, where most of your paid traffic actually lands.

Create a custom product template and assign it per product

You rarely want to change every product page. More often you want one layout for apparel (size chart, fit notes) and another for a mug or poster (dimensions, care). Shopify handles this with multiple templates of the same type.

In Edit code, open the templates folder, click Add a new template, choose product as the type, and name it something like product.apparel. On a 2.0 theme this creates templates/product.apparel.json, which you can build out in the theme editor with its own sections and blocks.

To assign it, leave the code editor and go to the product itself: in the product page's Theme template dropdown (right-hand sidebar), pick your custom template and save. That one product now renders your custom layout; everything else stays on the default. If you're organizing which products get which treatment, grouping them into collections first makes the assignment pass far faster.

The limits that quietly cap what you can build

Before you design an elaborate template, know the ceilings. A single JSON template can render a maximum of 25 sections, each section can hold up to 50 blocks, and a theme can carry up to 1,000 JSON templates in total — per Shopify's theme limits documentation.

Those numbers are generous for product pages — you will almost never hit 25 sections on one product. The one that bites is performance, not the cap: every extra section is more to render, and a product page bloated with eight apps' worth of blocks loads slowly for the exact mobile shoppers your Meta budget is paying to send there.

Treat the limits as a reminder to be deliberate, not as a target. A fast page with four sections that answer the buyer's real objections beats a maxed-out one every time.

Which product pages are worth the code

Here's what the how-to articles never tell you: custom template code is an investment, and most of your catalog doesn't deserve it. The pages worth an afternoon of Liquid are the ones carrying real order volume and real ad spend.

Say you run 340 orders a month at a $31 average order value, pushing $2,800 a month through Meta. Your catalog is 200 products, but the Pareto reality is that a handful of them take most of the spend. Walk the math on one.

A tee sells for $31. Your Printify cost is $12.40, your processor takes about $1.20, and you eat $4.50 of shipping — $18.10 in cost, leaving $12.90 before ads. If that one tee pulls 90 of your 340 orders and you're funneling $900 of the $2,800 budget behind it, your ad cost per order is $900 ÷ 90 = $10. Per-order profit: $12.90 − $10 = $2.90.

That tee's product page is where custom template code pays back — a bundle block that lifts AOV, a size guide that cuts returns, a shipping badge that lifts conversion. The same hours spent hand-coding a page that sells two units a month return nothing.

One more profit detail that changes what you build: when you refund an order, the original payment-processing fee is not returned to you, per Shopify's refunds documentation. On a thin $2.90-per-order product, a wave of returns from a misleading product photo erases the profit on several clean orders. A truthful size guide in your template is a margin tool, not just a UX nicety.

Knowing which pages earn — before you open the code editor

The hard part isn't the Liquid. It's knowing which products actually clear a profit once the ad spend and supplier cost land on them, because the Shopify sales report shows revenue, not margin.

This is the gap PodVector AI built Victor to close. Victor is an AI employee, not a dashboard — he connects to Shopify, Meta Ads, Google Ads, Printify, Printful, Gelato and Klaviyo, and because he sees every order, every ad dollar, and every supplier cost together, he computes the true per-order profit on each product. He delivers that as a report to your Google Drive, so you know which product pages are actually worth the custom template work before you clone the theme.

Victor acts, too — with your approval he can change a product's price or build a discount in Shopify, and shift budgets in Meta Ads and Google Ads. Every write action is approval-gated: he proposes, you approve, then it executes. That keeps the "which pages earn" decision and the "change the price on that page" action in the same place.

FAQs

Where is the product template file in Shopify?

On an Online Store 2.0 theme, the layout config is at templates/product.json and the real markup is in sections/main-product.liquid. On an older vintage theme it's a single templates/product.liquid. Reach both through Online Store > Themes > … > Edit code.

Do I need to know how to code to edit a product page?

Not for most changes. The theme editor (Customize) lets you add, remove, and reorder sections and blocks on a 2.0 product page with no code. You only need to touch sections/main-product.liquid for markup or logic the editor doesn't expose — and even then, always on a duplicated theme.

How do I give one product a different template without changing the rest?

Create a new template of type product in Edit code (for example product.apparel), build it, then open the specific product and select that template in its Theme template dropdown. Only that product changes; the default template keeps rendering everywhere else.

Will editing the product template delete my product descriptions or prices?

No. Template code controls how a page is laid out; your product titles, descriptions, images, and prices live on the product record itself, not in the theme. Switching or editing a theme leaves all of that product data intact — which is also why a theme change never touches the copy you wrote per product.

Can I edit product page code safely on a live store?

Only by duplicating the theme first and editing the copy. Edits to a live theme save instantly with no admin-side undo. Build on the duplicate, preview it on desktop and mobile, and publish once checkout and the variant picker both work.

How is template code different from a discount showing on the page?

Template code controls the layout and static elements; a live discount is applied by Shopify's discount engine and surfaced through theme blocks. If your goal is to make a sale price visible to shoppers, start with showing the discount on the product page rather than hand-coding price logic.

Where should I start if I manage a large catalog?

With your operations workflow, not the theme. The Shopify store operations guide covers the admin levers — collections, bulk edits, and customer segments — that decide which products deserve a custom template in the first place. Code the winners; leave the long tail on the default.