How to set up Shopify metafields, show them on product pages with Liquid, manage them through the API and fix the most common problems.
What metafields are for
Shopify metafields let you store extra data on products, customers and orders that the standard fields don't cover. On product pages, that might be ingredients, nutritional information or care instructions.
1. Set up your metafields
In the Shopify admin, go to Settings > Custom data. Pick the resource (products, for example), add a definition and choose its type and description. You can also create and manage metafields through the Shopify API.
Common metafield types
- Text: for words and sentences
- Integer: for whole numbers
- True or false: for yes/no values
- Date and time: for dates and timestamps
2. Show metafields on product pages
Once a metafield has a value, you can display it with Liquid, Shopify's templating language. For example, an ingredients field in the custom namespace is output with {{ product.metafields.custom.ingredients.value }}.
3. Make editing easy
Each definition shows up as a field on the product page in the admin. Your team can update values there without touching code.
4. Use metafields in your theme
Metafields work in any theme template. Care instructions, for example, can be output with {{ product.metafields.custom.care_instructions.value }}.
5. Manage metafields with the API
The Shopify API lets you create, update, delete and read metafields in code. That's how you connect them to your existing apps and workflows.
6. Follow a few simple rules
- Give every metafield a descriptive name and description.
- Choose the right type from the start. Changing it later is a hassle.
- Use the same metafields the same way across the whole store.
7. Fix common problems
Most issues come from the wrong field type, missing values or Liquid pointing at the wrong namespace or key. Check the definition in Settings > Custom data, then confirm the product has a value. You can also read values through the API to spot errors.
Further reading
The Shopify help center covers every metafield type, and this Shopify metafields tutorial on YouTube walks through the setup. For a broader look at how I build stores, read how I use Shopify for ecommerce stores.
Start with the two or three details customers ask about most and add more later. If you want help setting them up, that's part of my Shopify work.
If you want a hand with your own store, see my Shopify development services.
Category: Shopify