Kokil Thapa - Professional Web Developer in Nepal
Freelancer Web Developer in Nepal with 15+ Years of Experience

Kokil Thapa is an experienced full-stack web developer focused on building fast, secure, and scalable web applications. He helps businesses and individuals create SEO-friendly, user-focused digital platforms designed for long-term growth.

Shopify Metafields Complete Guide

By Kokil Thapa | Last reviewed: September 2026

Shopify metafields let you attach structured custom data to products, collections, customers, and other core objects without hacking the database. If you are building a theme, a custom app, or migrating from WooCommerce, this Shopify Metafields Complete Guide walks through definitions, types, Admin API calls, and Liquid rendering the way you would on a live store. I have used metafields on florist and multi-currency Shopify eCommerce builds where standard product fields could not hold care instructions, delivery zones, or B2B price tiers. The pattern is simple once you separate definitions from values.

What Are Shopify Metafields and Why Do Stores Need Them?

Every Shopify resource—product, variant, collection, customer, order, shop, page, blog, article—can carry extra metadata outside the built-in schema. Metafields solve problems native fields cannot: ingredient lists, size charts, warranty PDFs, SEO overrides, or Nepal-specific attributes like VAT notes and delivery ward codes.

Before Shopify shipped metafield definitions, merchants typed free-form keys in Admin. That led to typos, inconsistent namespaces, and broken theme logic. Definitions now enforce type, validation, and Admin UI rendering. Treat metafields as part of your data model, not a dumping ground.

Shopify Metafields ArchitectureResourceProduct, PageDefinitionType + validationValuePer resource rowAccess LayersAdmin UIAdmin APILiquid / StorefrontMerchant editsApps sync dataTheme output
Shopify Metafields Complete Guide: definitions describe shape; values hold per-item data; themes and APIs read the same namespace.key pair.

Common use cases I see on eCommerce development projects include:

  • Product specs (material, dimensions, care instructions) for filtered search
  • Collection hero copy and banner images beyond the default description field
  • Customer loyalty tier or wholesale account flags for B2B pricing rules
  • Page-level FAQ blocks and structured content for programmatic SEO
  • Order-level fulfilment notes synced from an ERP or warehouse system

Metafields do not replace a full PIM or CMS. They excel when Shopify remains the commerce source of truth and you need a dozen to a few hundred typed fields—not thousands of relational tables.

How Do You Create and Manage Metafield Definitions in Shopify Admin?

Definitions tell Shopify what type of data you expect and how to show it in Admin. Without a definition, a metafield still works in Liquid, but merchants get a raw key-value editor that invites mistakes.

Step-by-step in Shopify Admin (2026)

  1. Open Settings → Custom data in your Shopify admin.
  2. Choose the resource (Products, Variants, Collections, Customers, etc.).
  3. Click Add definition and set namespace, key, name, and type.
  4. Optionally pin the field to the resource detail page and set validation rules.
  5. Save, then open any product and fill the new field under the metafields section.

Pick namespaces deliberately. I standardise on custom for merchant-facing fields and app-specific namespaces like my_app for integration data. Never reuse the same key with different types across environments.

Namespace and key naming rules

Shopify allows letters, numbers, underscores, and hyphens. Keys are unique per namespace on a given resource. A practical pattern:

namespace: custom
key: care_instructions
type: multi_line_text_field

namespace: custom
key: size_chart_page
type: page_reference

namespace: shipping
key: delivery_zone_kathmandu
type: single_line_text_field

Document every namespace.key in your theme README or internal wiki. Future you—and the next developer—will need that map when debugging empty Liquid output.

What Metafield Types Should You Choose for Products and Pages?

Shopify supports scalar types (text, number, boolean, date, JSON), reference types (product, variant, collection, page, file), and list variants of most scalars. Type choice affects Admin UX, API validation, and how Liquid renders the value.

TypeBest forLiquid accessWatch out for
single_line_text_fieldSKU suffix, badge label, short specmetafield.value stringNo HTML; escape on output
multi_line_text_fieldCare instructions, ingredientsString with newlinesUse newline_to_br filter
rich_text_fieldFormatted product storiesStructured JSON or HTML via filterSchema markup needs plain text extraction
number_integer / number_decimalPack size, weight overrideNumeric comparison in LiquidUnits live in a separate field
file_referencePDF manual, size chart imagemetafield.value.urlCDN URL; check blank state
product_referenceCross-sell, bundle partsProduct objectCan trigger extra API cost in headless setups
jsonFlexible config blobsParse in Liquid or JSNo Admin validation beyond JSON syntax
list.single_line_text_fieldTags-like facets you controlLoop metafield.valueGood for filter apps and search

For Nepali storefronts selling physical goods, I often pair a multi_line_text_field for Nepali care copy with a single_line_text_field English summary. That keeps Unicode content manageable while preserving a shorter field for Google Merchant feeds.

Choose a Metafield TypeWhat are you storing?Plain textsingle or multi lineMedia or linkfile or URL typeRelationproduct_referenceList type if manyValidate in definitionExpose to StorefrontWrong type = broken Liquid filters and bad Admin UX
Type selection in the Shopify Metafields Complete Guide: match storage shape to render path before you bulk-import values.

How Do You Create Metafields with the Shopify Admin API?

For migrations, ERP sync, or custom apps, the GraphQL Admin API is the reliable path. Use API version 2026-07 or later so metafield definition mutations match current Shopify behaviour. REST metafield endpoints still exist, but GraphQL gives you typed definitions and bulk operations in one request.

Create a metafield definition via GraphQL

mutation CreateProductMetafieldDefinition {
  metafieldDefinitionCreate(
    definition: {
      name: "Care instructions"
      namespace: "custom"
      key: "care_instructions"
      type: "multi_line_text_field"
      ownerType: PRODUCT
      access: {
        admin: MERCHANT_READ_WRITE
        storefront: PUBLIC_READ
      }
    }
  ) {
    createdDefinition {
      id
      name
      namespace
      key
    }
    userErrors {
      field
      message
    }
  }
}

Set storefront: PUBLIC_READ when your Online Store 2.0 theme or headless Storefront API frontend must read the field. Keep integration-only fields private to avoid leaking wholesale cost data.

Set a value on one product

mutation SetProductMetafield($ownerId: ID!, $value: String!) {
  metafieldsSet(metafields: [{
    ownerId: $ownerId
    namespace: "custom"
    key: "care_instructions"
    type: "multi_line_text_field"
    value: $value
  }]) {
    metafields {
      id
      namespace
      key
      value
    }
    userErrors {
      field
      message
    }
  }
}

Pass the product GID as ownerId, for example gid://shopify/Product/1234567890. Bulk imports should use bulkOperationRunMutation when you are updating thousands of SKUs from a CSV export.

Rate limits and idempotency

Admin API calls cost points based on query complexity. Batch metafield writes inside a single metafieldsSet call when possible. On a real client project syncing daily inventory, I store the last successful sync timestamp in a shop metafield so retries skip unchanged rows.

Official reference: see Shopify’s metafields documentation and the Admin GraphQL API 2026-07 for current mutation names and access scopes (write_products, write_customers, etc.).

Metafield Setup Pipeline1. DefineAdmin or API2. PopulateCSV or sync3. ExposeStorefront access4. RenderLiquid themeTheme Integration (OS 2.0)sections/product.liquidproduct.metafields.custom.care_instructions{% if metafield != blank %} ... {% endif %}Always guard blank metafields in production themes
Production workflow for Shopify metafields: define once, populate safely, expose to Storefront, then render with blank checks in Liquid.

How Do You Output Metafields in Liquid Themes?

Online Store 2.0 themes read metafields through the resource object. Syntax follows resource.metafields.namespace.key. Dynamic sources in the theme editor can bind section settings directly to metafields—no hard-coded keys in JSON templates if you prefer merchant control.

Basic Liquid examples

{% assign care = product.metafields.custom.care_instructions %}
{% if care != blank %}
  <div class="product-care">
    <h3>Care instructions</h3>
    {{ care | metafield_tag }}
  </div>
{% endif %}

{% assign size_chart = product.metafields.custom.size_chart_page.value %}
{% if size_chart %}
  <a href="{{ size_chart.url }}">View size chart</a>
{% endif %}

The metafield_tag filter renders type-aware HTML for many field types. For rich text, it saves you from hand-parsing JSON. For plain strings, escape user content unless you fully trust the source.

Theme blocks and JSON templates

In a section schema, enable metafield pickers:

{
  "type": "text",
  "id": "subtitle",
  "label": "Product subtitle",
  "info": "Or bind a dynamic source to custom.subtitle metafield"
}

Merchants then connect dynamic sources in the theme customizer. Developers ship the section; merchandisers map fields without redeploying code. That split works well on WooCommerce-to-Shopify migrations where florists want editable petal-care notes per SKU.

Deeper Liquid patterns live in the Shopify custom theme development guide. Pair metafield-driven tabs with lazy-loaded images so Core Web Vitals stay within target on mobile Nepal networks.

What Are Common Shopify Metafield Mistakes and How Do You Fix Them?

Most production bugs are boring: wrong namespace, missing storefront access, or Liquid assuming a value exists on every variant. The fix is usually documentation and defensive templates—not another app.

Mistake 1: Skipping definitions before bulk import

CSV importers and custom scripts can write raw metafields fast. Without definitions, types drift ("12" as string vs integer) and Admin shows unreadable JSON. Create definitions first, then import values that pass validation.

Mistake 2: Forgetting storefront visibility

A metafield visible in Admin but hidden from Storefront returns blank in Liquid on the live theme. Re-check the definition access block after cloning stores from staging to production.

Mistake 3: Using metafields as a relational database

Storing huge JSON graphs or duplicating entire product catalogs inside one json metafield breaks down quickly. Use product references and metaobjects for structured entities. Metaobjects behave like custom content types with their own entries—ideal for store locators, author profiles, or certificate blocks on legal content sites.

Mistake 4: SEO duplication

Do not mirror the product description into a metafield and output both on the page. Pick one canonical body field. Use metafields for supplementary specs and JSON-LD helpers. Coordinate with your technical SEO process so structured data pulls from the same source Google Merchant Center expects.

Metafield Fixes: Before vs AfterBeforeNo definitionPrivate storefront accessUnescaped HTML outputDuplicate SEO body textBlank tabs on live themeBroken UX + crawl noiseAfterTyped definitionsPUBLIC_READ where neededmetafield_tag + if blankSingle canonical descriptionDocumented namespace mapStable theme + cleaner indexfix
Shopify Metafields Complete Guide: typical before/after fixes for blank theme output, access scopes, and duplicated SEO content.

When debugging, use GraphiQL or the JSON formatter tool to inspect metafield payloads returned from the Admin API. Compare staging and production GIDs carefully—IDs differ even when handles match.

How Do Metafields Compare to Metaobjects and Standard Fields?

FeatureStandard Shopify fieldsMetafieldsMetaobjects
PurposeCore commerce dataExtra attributes on existing resourcesReusable structured entries
Exampletitle, price, imagecare_instructions on a productStore location with hours and map
Admin UXFixedPinned on resource pagesOwn entry list
APIProductInput fieldsmetafieldsSetmetaobjectCreate
Theme accessproduct.titleproduct.metafields.custom.keyshop.metaobjects.type.handle
Best whenShopify-native conceptsA few fields per resourceMany shared structured records

Choosing between platforms? The Magento 2 vs Shopify vs WooCommerce comparison covers where metafields fit Shopify’s lighter custom-data model versus EAV-heavy Magento attributes or WordPress post meta.

For custom apps that write metafields at scale, follow the same auth and webhook patterns described in the Shopify Admin API development guide. If you outgrow Admin API throughput, queue writes and reconcile with a nightly full sync job.

Key Takeaways

  • Create metafield definitions before bulk imports so types and Admin UI stay consistent across environments.
  • Set storefront: PUBLIC_READ on any field your Liquid theme or headless storefront must render.
  • Use namespace.key conventions (custom.care_instructions) and document them for merchants and developers.
  • Guard every Liquid output with blank checks; use metafield_tag for type-safe rendering where available.
  • Prefer metaobjects when you need reusable structured entries, not giant JSON blobs in a single metafield.
  • Align metafield-driven content with SEO and feed strategy so you do not duplicate body copy Google already indexes.

People Also Ask

What is the difference between metafields and metaobjects in Shopify?

Metafields attach extra fields to an existing resource like a product or customer. Metaobjects are standalone structured records—think store locations or recipe cards—that you reference from metafields. Use metafields for per-SKU data; use metaobjects when the same structure repeats across many entries.

Can Shopify metafields be used for search and filtering?

Yes. List-type metafields and typed definitions power Shopify Search & Discovery filters when configured in Admin. Third-party search apps also index public metafields via the Storefront API. Keep facet values normalised—mixed spelling in a list field breaks filter UX.

Do metafields work with Shopify Markets and B2B?

Metafields are store-scoped unless your integration copies them per market catalog. For B2B price lists, combine customer metafields with Shopify B2B company locations rather than storing prices in unsecured product metafields visible on Storefront.

How many metafields can a Shopify product have?

Shopify enforces per-resource limits that change over time; check current platform limits in Shopify Help before architecting hundreds of keys per SKU. In practice, stay well below the cap—group related data into metaobjects or JSON only when the shape is truly nested.

Build Custom Data Models on Shopify With Confidence

Metafields are the cleanest way to extend Shopify products and pages without fighting the core schema. This Shopify Metafields Complete Guide gives you the definition-first workflow, API mutations for Admin API 2026-07, and Liquid patterns that survive merchant edits and theme updates. Start with a short namespace map, expose only what the storefront needs, and validate before you import ten thousand rows from a legacy catalog.

Need help mapping metafields for a migration, custom theme, or ERP sync on a Nepal or international store? Review our eCommerce development services, browse the Nepal Gift Card and Petals Agro Nepal portfolio work, or contact us to plan your custom data layer before go-live.

Frequently Asked Questions

Shopify metafields are key-value custom fields attached to products, collections, customers, and other core Shopify resources, extending data beyond the built-in schema.

Open Settings, then Custom data, choose the resource such as Products or Variants, and click Add definition. Set namespace, key, name, and type, optionally pin the field to the resource detail page, and add validation rules. Save, then open any product and fill the new field under its metafields section. Definitions enforce type and Admin UI rendering; without them merchants get a raw key-value editor that invites typos, inconsistent namespaces, and broken theme logic on live stores.

Match storage shape to how you will render the value. Use single_line_text_field for short specs and badge labels, multi_line_text_field for care instructions, rich_text_field for formatted stories, file_reference for PDF manuals, product_reference for cross-sells, and list.single_line_text_field for controlled facets. Type choice affects Admin UX, API validation, and Liquid output. For Nepali storefronts selling physical goods, pairing a multi_line_text_field for Unicode care copy with a shorter English single_line_text_field keeps feeds manageable while preserving full local-language content.

Use the GraphQL Admin API version 2026-07 or later. Create definitions with metafieldDefinitionCreate, setting namespace, key, type, ownerType, and access scopes including storefront visibility. Set values with metafieldsSet, passing the owner GID such as gid://shopify/Product/1234567890. Set storefront to PUBLIC_READ when your Online Store 2.0 theme or headless Storefront API frontend must read the field. Batch writes inside a single metafieldsSet call when possible, and use bulkOperationRunMutation when updating thousands of SKUs from a CSV export.

Online Store 2.0 themes read metafields through the resource object using resource.metafields.namespace.key syntax, for example product.metafields.custom.care_instructions. Always guard output with blank checks before rendering. Use the metafield_tag filter for type-aware HTML on rich text and similar types. For page references, read metafield.value.url. Theme editor dynamic sources can bind section settings directly to metafields so merchants map fields without redeploying code, which works well after WooCommerce-to-Shopify migrations where florists want editable care notes per SKU.

Metafields add typed fields to existing resources like products or customers. Metaobjects are standalone structured records with their own entry lists, referenced from metafields for repeating data like store locators.

The most common cause is missing storefront visibility on the definition. A metafield visible in Admin but hidden from Storefront returns blank in Liquid even though the value exists. Re-check the definition access block after cloning staging to production and confirm storefront is set to PUBLIC_READ. Also verify namespace and key spelling in Liquid matches your documented custom.care_instructions pattern, and confirm the value is set on that exact product or variant rather than assumed on every sibling in the collection.

Yes. List-type metafields and typed definitions can power Shopify Search and Discovery filters when configured in Admin. Third-party search apps also index public metafields via the Storefront API. Keep facet values normalised because mixed spelling in a list field breaks filter UX. Treat list.single_line_text_field values as a controlled vocabulary merchants maintain consistently, not free-form tags typed differently per SKU during bulk imports.

Metafields are store-scoped unless your integration copies them per market catalog. For B2B price lists, combine customer metafields with Shopify B2B company locations rather than storing prices in unsecured product metafields visible on Storefront. Keep integration-only fields private in the definition access block to avoid leaking wholesale cost data. I have seen production issues where PUBLIC_READ was set broadly for convenience and sensitive tier pricing appeared in theme output or Storefront API responses.

Shopify enforces per-resource limits that change over time; check current platform limits in Shopify Help before architecting hundreds of keys per SKU. In practice, stay well below the cap.

Shopify allows letters, numbers, underscores, and hyphens in namespaces and keys. Keys are unique per namespace on a given resource. Standardise on custom for merchant-facing fields and app-specific namespaces like my_app for integration data. Never reuse the same key with different types across environments. Document every namespace.key in your theme README or internal wiki. Practical patterns include custom.care_instructions as multi_line_text_field, custom.size_chart_page as page_reference, and shipping.delivery_zone_kathmandu as single_line_text_field for location-specific delivery rules.

Use metafields when you need a few extra attributes on an existing product, collection, or customer record. Use metaobjects when you need many reusable structured entries such as store locations with hours and maps, author profiles, or certificate blocks on legal content sites. Avoid storing huge JSON graphs or duplicating entire product catalogs inside one json metafield. Product references and metaobjects handle structured entities more cleanly, preserve Admin validation, and stay maintainable as your catalog grows.

Skipping definitions before bulk import causes type drift, such as 12 stored as a string instead of an integer. Forgetting storefront visibility leaves Liquid output blank on production themes. Using metafields as a relational database with giant JSON blobs breaks down quickly under real catalog load. Mirroring product descriptions into metafields creates SEO duplication Google already indexes elsewhere. Fix each by defining first, setting PUBLIC_READ only where the theme needs it, preferring metaobjects for shared structures, and picking one canonical body field coordinated with your technical SEO and Merchant Center feed strategy.

REST metafield endpoints still exist, but GraphQL Admin API 2026-07 or later is the reliable path for migrations, ERP sync, and custom apps. GraphQL gives typed definitions and bulk operations in one request, which REST does not match as cleanly. Production workflow is define once, populate safely with metafieldsSet, expose Storefront-readable fields, then render with blank checks in Liquid. Admin API calls cost points based on query complexity, so batch metafield writes when possible. If throughput becomes a bottleneck, queue writes and reconcile with a nightly full sync job.

No. Metafields excel when Shopify remains the commerce source of truth and you need a dozen to a few hundred typed fields, not thousands of relational tables. They solve gaps native fields cannot fill, such as ingredient lists, size charts, warranty PDFs, SEO overrides, or Nepal-specific attributes like VAT notes and delivery ward codes. Treat metafields as part of your data model, not a dumping ground. When structured content repeats across many entries or relationships grow complex, metaobjects and dedicated integration systems are the safer long-term choice.

Share this article

0 Comments

Leave a comment

Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

Quick Contact Options
Choose how you want to connect me: