Shopify Metafield Liquid Generator

Pick the owner and type, and get the exact Liquid to display a metafield, with blank checks and list loops handled for you.

Describe the result you need. AI will set up the tool and ask for any missing details.

Configure with AI

Enter to submit · Shift + Enter for a new line

Sent to AI. Leave out passwords and private customer data.

Your details

Where it's attached

The group the field belongs to. Metafields you add directly in the Shopify admin use "custom" by default.

Field type
Output

Liquid to paste into your theme

liquid
{% if product.metafields.custom.my_field.value != blank %}
  {{ product.metafields.custom.my_field.value }}
{% endif %}

Add the definition first in your Shopify admin (Settings → Custom data → Product), with this exact namespace and key: custom.my_field. Until then this will render blank.

How metafield Liquid is built

Every metafield lives at {owner}.metafields.{namespace}.{key}, where owner is an object like product or collection, namespace groups related fields (Shopify's admin uses custom by default), and key is the field's name. Reading .value gives you the field's content, formatted for its type.

TypeWhat .value returnsHow to output it
Text, number, URL, colorThe raw value{{ field.value }}
Booleantrue or false{% if field.value %}
RatingAn object with .value and .scale_max{{ field.value.value }} out of {{ field.value.scale_max }}
Weight, volume, dimensionAn object with .value and .unit{{ field.value.value }} {{ field.value.unit }}
Reference (product, page…)The referenced object{{ field.value.title }}
Metaobject referenceThe metaobject{{ field.value.some_field.value }}
File, rich text, rating, color, boolean, URL, metaobjectNot needed{{ field | metafield_tag }}, which renders ready-made HTML for the type

For a list metafield (any type prefixed list.), .value is an array, so wrap the output in {% for item in field.value %}…{% endfor %} and use item where you'd otherwise write field.value.

Default settings

Owner
Product
Namespace.key
custom.my_field
Type
Single line text

{% if product.metafields.custom.my_field.value != blank %} {{ product.metafields.custom.my_field.value }} {% endif %}

Setting up the metafield first

  1. 01

    Add the definition

    In your Shopify admin, go to Settings → Custom data, choose the resource (Products, Collections, and so on), and click Add definition. Set the namespace and key to match exactly what this tool generated.

  2. 02

    Fill it in per product

    Open a product (or the resource you chose) and scroll to the Metafields section near the bottom to enter a value.

  3. 03

    Paste the Liquid

    In Online Store → Themes → Edit code, open the section or snippet where the field should appear and paste the generated code.

If nothing shows up, double-check the namespace and key match your definition exactly, and that the product you're viewing actually has a value saved.

Questions people ask

What's the difference between metafield_tag and .value?

.value gives you the raw data so you control the markup yourself. metafield_tag renders Shopify's own ready-made HTML for the type (an <img> for files, a <span> for ratings and colors), which is faster to use but less flexible to style.

Why is my metafield showing blank?

Either the namespace or key doesn't match your metafield definition exactly, the product you're viewing has no value saved for it, or (for a variant) you're reading it from the wrong object. Metafields are case-sensitive.

Can I use this for order or customer metafields?

Yes, pick Order or Customer as the owner. Order metafields only render in order status and notification Liquid, not in your online storefront theme.

What does the namespace "custom" mean?

It's the default group Shopify's admin uses when you add a metafield definition yourself, without an app. Apps usually use their own namespace instead.

How do I read one field from a metaobject?

Enter the metaobject field's key (for example "name" or "description") in "Metaobject field to read." The generated Liquid becomes {{ field.value.name.value }}.

Want this builtinto your store?

I'm Emmanuel, a Shopify and WooCommerce developer. If this tool pointed at something you'd rather have fixed for you (a faster store, cleaner product data, a migration, a custom feature), send me a note.

Emmanuel Asika

Emmanuel Asika

Shopify & WooCommerce developer, Dublin

I build and fix online stores: new builds, migrations, speed, SEO and the custom bits apps can't do.

hello@emmanuelasika.com