Metafields in Shopify allow you to store extra information about products, collections, customers, orders, and more. They are useful when you need to add custom data that isn’t available in Shopify’s default fields.
1. What Are Shopify Metafields?
Metafields are custom fields that you can add to different Shopify objects (like products, variants, collections, orders, etc.). They allow you to store and display additional information, such as:
- Product specifications (e.g., weight, dimensions, material)
- Extra product images or videos
- SEO descriptions
- Custom order notes
- Additional customer details
2. How Do Shopify Metafields Work?
Each metafield consists of:
- Namespace – Groups related metafields (e.g.,
custom
) - Key – Unique identifier for the metafield (e.g.,
fabric
) - Type – The kind of data (e.g.,
string
,integer
,json
) - Value – The actual content (e.g.,
"Cotton"
)
3. Adding Metafields in Shopify Admin
Shopify allows you to create and manage metafields without code. Follow these steps:
Step 1: Enable Metafields in Shopify
- Go to your Shopify admin panel.
- Click on Settings → Custom data.
- Select the resource you want to add a metafield to (e.g., Products).
- Click Add definition to create a new metafield.
Step 2: Define the Metafield
- Namespace:
custom
- Key:
fabric
- Type:
Single line text
- Validation rules: Set optional rules (e.g., required)
- Click Save.
Step 3: Add Values to Metafields
- Go to Products and select a product.
- Scroll to the Metafields section at the bottom.
- Click on the metafield and enter a value (e.g.,
"Cotton"
). - Save the product.
4. Accessing Metafields in Shopify Theme (Liquid)
If you want to display the metafield on your product page, add this Liquid code to your theme:
{{ product.metafields.custom.fabric }}
This will output "Cotton"
on the product page.
Example: Show Fabric Type in a Product Description
Modify product-template.liquid
in your theme editor:
<p>Fabric: {{ product.metafields.custom.fabric }}</p>
5. Managing Metafields via Shopify API
If you’re a developer, you can also create, update, and retrieve metafields using the Shopify API.
Example: Create a Metafield for a Product (REST API)
Use the following API request:
POST /admin/api/2024-01/products/123456789/metafields.json
{
"metafield": {
"namespace": "custom",
"key": "fabric",
"value": "Cotton",
"type": "single_line_text_field"
}
}
For more advanced metafield operations, use Shopify’s GraphQL API.
6. Using Metafields in Shopify Apps
If you’re using Shopify apps like Shopify Metafields Guru or Accentuate Custom Fields, you can manage metafields without coding.
Popular Apps for Metafields
- Shopify Metafields Guru – Free & easy-to-use
- Accentuate Custom Fields – Advanced field management
7. Practical Use Cases for Metafields
- Adding Custom Size Charts
- Create a metafield for
size_chart_url
- Display it using:
<a href="{{ product.metafields.custom.size_chart_url }}">View Size Chart</a>
- Create a metafield for
- Displaying Extra Product Details
- Store
warranty_period
in a metafield. - Use:
<p>Warranty: {{ product.metafields.custom.warranty_period }} years</p>
- Store
- Adding Customer Customizations
- Store
engraving_text
for personalized products.
- Store
Summary
Shopify Metafields provide powerful customization options for your store. Whether you’re adding extra product details, managing custom fields via API, or using apps, they help improve store flexibility.
If you’re developing custom Shopify themes or apps, mastering metafields will help you create more personalized shopping experiences.