Metafields vs Custom Templates in Shopify
What factors should I consider when choosing to use a custom template for collections or use metafields in a shopify theme development?
This is a classic “layout vs. content” trade-off in Shopify. Here’s a practical way to decide between custom collection templates and metafields when building themes.
When to use a custom template (JSON template)
Use a distinct template if you need different structure or composition, not just different text/images.
Different layout/sections
- e.g., Collection A has a hero + featured brands + editorial block; Collection B has a filter bar + size guide accordion.
- You want different section types or a different section order that can’t be toggled with settings alone.
App or script needs a template handle
- Some apps or custom scripts target a specific template name (e.g.,
collection.brand.json) for mounting widgets or different schemas.
- Some apps or custom scripts target a specific template name (e.g.,
Landing page–style collections
- Collections that behave more like editorial landing pages than product grids.
Merchandising UX
- It’s simpler for merchandisers to switch a collection’s “Theme template” than to manage a lot of per-collection settings.
Performance of conditional logic
- If you’re otherwise piling on complex Liquid conditionals to mimic different layouts, a clean separate template can be clearer and faster.
Watch-outs
- Template sprawl & maintenance: Every new template is another JSON file to maintain/test.
- Theme-specific: Templates live in the theme. If you change themes, you must recreate them.
- Soft limits: Shopify imposes limits on how many templates a theme can have; avoid exploding counts with near-duplicates.
When to use metafields (resource data)
Use metafields when the layout stays the same but content varies per collection.
Same structure, different content
- e.g., per-collection hero image, subtitle, promo banner copy, SEO blurb, size guide link, icon set, or a “featured collection” reference.
Reusable components bound to dynamic sources
- In sections, bind settings to
collection.metafields.*so the same section pulls different data per collection without adding templates.
- In sections, bind settings to
Portability & upgrades
- Metafields are stored on the collection resource, so they survive theme changes and re-platforming of the theme.
Governance
- Define metafield definitions with validation and “required” where appropriate; this enforces content completeness for merchandisers.
Localization
- Translatable metafields let you localize content per market/language without cloning templates.
Watch-outs
- Overloading a “generic” template: If you’re using metafields to flip whole layouts, you’ll end up with fragile Liquid conditionals. That’s a sign to split templates.
- Content entry complexity: Too many metafields can overwhelm admins; group them and name clearly.
Quick decision guide
Does the section composition differ?
- Yes → Custom template
- No, only content differs → Metafields
Do apps/scripts need a unique template handle?
- Yes → Custom template
- No → Metafields likely
Will the site switch themes soon / often?
- Yes → Prefer Metafields for portability
How many variants are there?
- Dozens/hundreds with small content tweaks → Metafields (avoid template sprawl)
Are editors comfortable managing many fields?
- If not, and the differences are chunky → Custom templates with simpler settings
Implementation patterns
Metafields you’ll commonly add to collections
collection.metafields.custom.hero_image(file reference)collection.metafields.custom.kicker/subtitle(single line text)collection.metafields.custom.promo_banner(rich text)collection.metafields.custom.size_guide(URL or page reference)collection.metafields.custom.featured_products(list of product references)collection.metafields.custom.badges(list of text)
Bind these as dynamic sources in section settings to keep the schema clean.
Clean section logic (metafields-first)
- Keep one “Collection Hero” section whose settings are bound to metafields.
- Use minimal Liquid conditionals (e.g., render a promo block only if the metafield is set).
- Avoid conditionals that swap out entire sections—split templates instead.
Custom template hygiene
- Start from a base
collection.jsonand createcollection.brand.json,collection.editorial.json, etc. - Keep shared sections DRY (same section files used by multiple templates, with small settings differences).
- Name templates by intent, not a single client’s brand (“editorial”, “brand-hub”, “lookbook”), so they scale.
Non-obvious considerations
- SEO: Multiple templates don’t create new URLs; they change markup and content. Ensure each collection has sufficient unique copy (metafield-driven blurbs help) to avoid thin pages.
- Filtering/sorting: If you change filters per layout, a template split is clearer than injecting filter config via metafields.
- Analytics: Unique template handles can simplify tracking (fire different data-layer events by template).
- Performance: Metafields are resolved server-side; the main perf risk is excessive conditional branching and heavy sections.
- Content modeling: If multiple resources (collections, products, pages) reuse the same content, prefer metafields with reference types over duplicating fields in each template.
- Editor workflow: For frequent, small updates (e.g., seasonal banner), metafields are faster and safer than editing template JSON.
Anti-patterns to avoid
- Creating a new template just to swap copy or a single image → use metafields.
- Using metafields to toggle between entirely different page architectures → make separate templates.
- Duplicating nearly identical templates for minor spacing/colors → move those to section settings.
A simple rule of thumb
- Layout/structure changes → Custom template.
- Content/settings changes → Metafields.
If you want, tell me a couple of concrete differences you’re planning (e.g., “Brand collections need a logo wall and a story block; category collections need filters and a size guide”), and I’ll sketch the exact metafield definitions and the minimal set of templates/sections to implement it cleanly.