Guide · Shopify sections

Using metafields inside
Shopify sections

Metafields let you attach structured data to products, variants, collections, and orders. In sections, they're the right way to display per-product content that doesn't fit the standard schema — without an app, and without JavaScript.

What metafields are for

Structured product data

Materials, care instructions, certifications, dimensions, fit notes — data that's too specific to live in the product description and too variable to put in a variant option. Metafields give each product its own structured fields, editable from the admin, renderable in any section.

Content that varies per product

A "How it's made" block that differs for each SKU. A FAQ list that's product-specific. A sizing chart that changes per collection. These are all metafield use cases — one field definition, different values per resource.

App replacement

Many apps exist solely to manage and display structured product data — tabs, accordions, size guides, ingredient lists. Native metafields + a custom section replaces most of them with no subscription fee and better performance.

Accessing metafields in Liquid

01

The metafield object syntax

Metafields are accessed via resource.metafields.namespace.key. For a product metafield with namespace custom and key care_instructions: {{ product.metafields.custom.care_instructions }}. This renders the raw value. For typed values like richtext or file references, use the appropriate filter.

02

Metafield value types

Shopify metafields have types that affect rendering. single_line_text_field outputs a string. multi_line_text_field outputs text with newlines. rich_text_field outputs HTML — pipe through | metafield_tag to render it safely. file_reference returns a file object — use .value to get the file, then | image_url.

03

List metafields

List type metafields return an array you iterate with for. A list.single_line_text_field with key materials would render as: {% for item in product.metafields.custom.materials.value %} ... {% endfor %}. Always access .value on list types — the metafield object itself is not the array.

04

Guarding nil values

Not every product will have every metafield filled in. Always guard with {% if product.metafields.custom.care_instructions %} before rendering. An unfilled metafield returns nil — rendering it without a check outputs nothing, but iterating over nil as a list throws an error.

Wiring metafields to section settings

01

metaobject and metafield setting types

Shopify's schema supports metaobject and metaobject_list setting types — the merchant selects a metaobject entry from the admin, and the section renders its fields. This is useful for structured content like team members, FAQs, or spec tables that the merchant manages as their own resource type.

02

Dynamic sources

In the Theme Editor, merchants can connect any setting to a dynamic source — including metafields — via the "Connect dynamic source" button. For this to work, the section must be on a template type that has a matching resource (product template for product metafields). The section doesn't need special code — Shopify handles the binding.

Related