← Back to guides
AdvancedSchemaLiquid · Published 2024-05-18 · 4 min read

Shopify Metafields Beginner Tutorial

Go beyond standard titles and descriptions. Use Metafields to store custom data for products, collections, and articles.

Share with Shopify developers — useful guides spread faster in theme dev communities.

When standard fields are not enough

Product titles and descriptions cover catalog basics. Metafields store structured extras—material, care instructions, size charts, collection banner copy—that templates read via Liquid. A practical implementation usually needs a definition in admin, a namespace/key contract, and blank guards in templates.

Definitions: namespace and key

Create definitions under Settings → Custom data. Each field has a namespace and key. In Liquid:

{{ product.metafields.custom.care_guide }}

During theme customization, empty output often means the metafield was never filled, the namespace changed after migration, or the definition targets variants while the template reads product level.

Types and safe output

  • Single line text: output with | escape inside a blank guard
  • Rich text: use | metafield_tag—not raw output
  • List types: loop .value in modern Liquid
{% if product.metafields.custom.care_guide != blank %}
  <div class="care-guide rte">
    {{ product.metafields.custom.care_guide | metafield_tag }}
  </div>
{% endif %}

Fallback handling

Never assume a metafield exists on every product. Use {% if != blank %} or provide a section setting fallback when data is optional.

{% assign material = product.metafields.custom.material %}
{% if material != blank %}
  <p>Material: {{ material | escape }}</p>
{% endif %}

Collections and articles

{{ collection.metafields.custom.banner_text | escape }}
{{ article.metafields.custom.series_name | escape }}

Takeaway

Metafields extend Shopify objects—document namespace keys like an API, guard blanks, and match output filters to field types. Layout toggles belong in Dynamic Settings.

Metafields fail silently in production

The most common "bug" is an empty metafield—not wrong Liquid. Merchant never filled the field, namespace changed after migration, or the definition targets variants but the template reads product level. Always {% if != blank %} before output and verify definitions in admin on staging.

Namespace discipline on agency projects

One namespace contract per client—document custom.ingredients, custom.care_guide, etc. in handoff docs. Mixing global and custom namespaces across snippets causes rescue projects where half the templates reference obsolete keys.

List and metaobject metafields

{% for item in product.metafields.custom.highlights.value %}
  <li>{{ item }}</li>
{% endfor %}

List types need .value in modern Liquid. Metaobjects power complex content models—start simple with product metafields before jumping to metaobject templates.

Connecting schema to metafields

Dynamic sources let section settings bind to metafields—when the binding breaks, settings look frozen. Document which sections use dynamic sources at handoff. Deeper patterns: metafields on client stores.

Troubleshooting

  • Blank output → check definition namespace/key in admin
  • HTML stripped → use metafield_tag for rich text types
  • Works in admin preview, not storefront → wrong template or market scope

Step by step: add a "Material" field to products

Here is the complete path from creating a metafield to showing it on the storefront.

  1. In the Shopify admin open Settings, then Custom data, then Products.
  2. Click Add definition. Name it Material. Shopify generates the key from the name, for example custom.material.
  3. Choose the content type, here Single line text, and save.
  4. Open any product. A new Material field now appears near the bottom. Enter a value such as "Stoneware".

Show it in a section

Metafields are read through the object they belong to, using the namespace and key. In a product section:

{% if product.metafields.custom.material.value != blank %}
  <p class="product__material">Material: {{ product.metafields.custom.material.value }}</p>
{% endif %}

The if check matters. Without it, products that have no value would show an empty "Material:" label.

Pick the right type

  • Single line text: short labels like material or care level.
  • Multi-line text / rich text: longer descriptions.
  • Integer or decimal: measurements you may want to calculate with.
  • File or image reference: size charts and extra photos.
  • True or false: simple flags such as "Handmade".

Common mistakes

  • Forgetting .value. Without it you output the whole metafield object, not its content.
  • Using a different namespace or key than the one in the definition. They must match exactly.
  • Expecting a metafield to appear on the storefront automatically. It only shows where your theme code or a dynamic source in the theme editor reads it.

In the theme editor, many settings also offer a Connect dynamic source button. That lets a merchant link a heading or image to a metafield without any code, which is a good way to make your own sections flexible.

Topic cluster

Schema

Section schema, settings, blocks, and theme editor integration.

Convert your HTML to Shopify Liquid

Paste a module, generate Liquid + schema, then copy the result into your theme. Free to try—no signup required for a sample conversion.

Share

Share this guide

Found this guide useful? Share it with other Shopify developers on LinkedIn, X, or Reddit.