Metafields

Read storefront-visible custom values and handle their typed or referenced data.

Supported resources expose storefront-visible metafields as namespace/key values. For example, product.metafields.details.material reads the material key in the details namespace. Only definitions marked storefront-visible are included. Check for missing namespaces and values before rendering them.

vascula
{% assign details = product.metafields.details %}
{% if details.material %}
  <p>Material: {{ details.material }}</p>
{% endif %}

Definition type

Value in CTX

string, multi_line_text, url, color

String (multi-line text keeps its line breaks; print it with newline_to_br. A color is #rrggbb, lowercase.)

rich_text

Sanitized HTML, printed as markup

date, datetime

Date value for the date filter; ISO text when printed or serialized, with datetime in the store timezone

integer, decimal

Number for a valid stored numeric value

boolean

Boolean

json

Parsed JSON value

list.string, list.url, list.color

Array of strings

single_select

Localized display label when the choice is available

list.single_select

Array of choice labels

file_reference

File object with id, url, and alt_text when the file resolves

list.file_reference

Array of resolved file objects

product_reference

Visible product card, or null when unavailable

list.product_reference

Array of visible product cards; unavailable entries are omitted

variant_reference, list.variant_reference

Visible variant object with its product, or an array of those objects; unavailable entries are omitted

page_reference, list.page_reference

The page as a page setting resolves it (id, url, title, slug, content and its metafields), or an array of those; a page not published in the shopper's language is null or omitted

blog_post_reference, list.blog_post_reference

The blog post as a blog post setting resolves it (post fields without content and comments), or an array of those; a post that is not shown is null or omitted

collection_reference, list.collection_reference

The collection as a collection setting resolves it (id, name, slug, url, product_count, image, description, metafields), or an array of those; unavailable entries are null or omitted

metaobject_reference, list.metaobject_reference

The custom content entry as a metaobject setting resolves it (id, handle, type, display_name, url, seo and its fields), or an array of those; a draft or deleted entry, or one of a type that is not storefront visible, is null or omitted. Custom content references inside entries resolve up to three levels deep (see Custom content)

Translations and missing choices#

When the definition is translatable, text values and choice labels use the shopper's exact locale, then its base language, then the source value or label. Empty translations fall through. Select values in CTX are display labels; API values remain canonical keys. Turning translation off uses the source value or label. Removing choices still used by stored values is rejected; clear or update those values first.

References#

Product and variant references resolve to cards visible on the current storefront, including on listing cards. Resolution batches pending references and admits at most 256 distinct product/variant references per request. Unavailable, deleted or over-budget single references are null; lists omit those entries. Raw reference IDs are not exposed as replacement values. Expansion stops after one level: referenced cards can carry their own metafields, but references inside those cards remain absent. Files resolve in a separate batch to media objects with URLs and localized alternative text.

A missing file, or a value that no longer matches its definition, may not resolve to the expected typed object. Keep metafield values consistent with their definitions, and render optional values only when they have the required shape. Use the dedicated product and cart price fields for purchasing, rather than treating a custom numeric metafield as a price.

See Shared data shapes for product cards and money objects, and Theme documentation for section settings and resource pickers.