← Back to guides
AdvancedLiquid · 2024-05-18

Shopify Metafields Beginner Tutorial

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

What are Metafields?

Metafields allow you to add custom fields to Shopify objects. If you sell t-shirts, you might want a specific field for "Material" or "Care Instructions" that doesn't fit nicely in the main product description.

The Syntax

Accessing a metafield in Liquid requires three parts: the object, the namespace, and the key.

{{ product.metafields.namespace.key }}

A Real World Example

Let's say you created a metafield in the Shopify Admin with the namespace custom and the key care_guide.

{% if product.metafields.custom.care_guide != blank %}
  <div class="care-guide">
    <h3>Care Instructions</h3>
    <p>{{ product.metafields.custom.care_guide }}</p>
  </div>
{% endif %}

Using Metafields as Rich Text

If your metafield is a "Rich text" type, you should use the metafield_tag filter to safely render the HTML.

{{ product.metafields.custom.details | metafield_tag }}

Where to Create Metafields

In Shopify admin: Settings → Custom data. Choose Product, Collection, or other definitions, then add fields with a namespace and key. In Liquid you reference custom namespace fields as product.metafields.custom.your_key.

Metafields on Collections & Articles

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

Combine metafields with section settings for flexible layouts—see Dynamic Settings.

Build faster with HTMLToLiquid Converter

Convert static HTML into dynamic Shopify sections.

Open converter