what are metafields?

Metafields let you attach custom data to almost any Shopify object — products, variants, collections, customers, and orders. Once set, you can surface them in your theme using Liquid without installing an app.

reading a metafield in liquid

{{ product.metafields.custom.size_guide }}

The namespace is custom, the key is size_guide. Shopify's Online Store 2.0 themes expose metafields in the schema editor so merchants can bind them without touching code.

displaying a file metafield

{% assign guide = product.metafields.custom.size_guide.value %}
{% if guide != blank %}
  <img src="{{ guide | image_url: width: 800 }}" alt="size guide">
{% endif %}

filtering collections by metafield

You can use collection.metafields to drive custom badges, conditional layouts, or category-specific content. Combine with where in arrays for advanced filtering inside your theme sections.

tips

  • Use Settings → Custom data in the Shopify admin to create metafield definitions with type validation.
  • Prefer namespace custom for theme-controlled data; reserve app--* namespaces for app metafields.
  • Rich text metafields render as HTML — output them with {{ value }} directly, already sanitised by Liquid.
  • Test metafield availability with {% if product.metafields.custom.my_key != blank %} before rendering.