Metafields Store Custom Data in Shopify

Metafields are custom fields you can add to several areas of your Shopify store and connect them to your theme using the Theme Editor.

Not every new Shopify feature is worth getting overly excited about. Metafields and their close relative, metaobjects, are distinct. 

They are both easy to set up and can save significant time when updating your Shopify online store.

What Are Metafields?

Suppose you want to add products to your Shopify online store. Each product needs to include a detailed list of ingredients. Previously, you had to add this information to the product description, which worked fine. However, you couldn't display the ingredients separately from the product description, such as in a collapsible tab.

This is where Shopify's metafields come in handy.

With metafields, you can add custom fields to your products, variants, collections, customers, orders, blog posts, and other areas of your Shopify store. The limit is 250 for each object, independent of your Shopify plan.

You can add these metafields to your online store using your Shopify Admin Panel.

Here is the best thing: If you are using a Shopify 2.0 Theme, you can easily connect these metafields to your theme using the Theme Editor without having to change your theme code. That's huge news because everyone can use this feature in their theme.

How to Add a Metafield

Adding a metafield to your Shopify online store is straightforward.

  1. Go to Shopify Admin > Content > Metaobjects.

  2. Click Manage Definitions.

  3. Under Metafield Definitions, select an object. For example, choose Products to add a metafield to the product object or Customers to add a metafield to the customer object.

  4. Click Assigned to all Products.

  5. Click Add Definition.

  6. Enter a Name and a Description.

  7. Select a Metafield Content Type. A content type defines the information a metafield captures. For example, if you want to enter single-line text, select the Single-Line Text content type. You can write single-line text but not multi-line text. Before choosing a content type, consider what kind of data you want to store.

How to Change the Order Metafields Are Displayed

Sometimes, you want to enter the metafields in a particular order.

  1. Go to Shopify Admin > Content > Metaobjects.

  2. Click Manage Definitions.

  3. Under Metafield Definitions, select an object. For example, choose Products to change the order of the metafields belonging to the product object.

  4. Click Assigned to all Products.

  5. Change the order of the metafields by moving the icon with the six dots on the left up or down.

How to Connect a Metafield to a Theme Using the Theme Editor

If your online store is based on a Shopify 2.0 theme, you can use the built-in Theme Editor to connect a metafield to your theme in just a few easy steps. There is no programming required.

  1. Go to Shopify Admin > Online Store.

  2. Under your current theme, click Customize.

  3. Select the page template at the top of the Theme Editor, for example, Home Page or Products > Default Product.

  4. Add a new section or add a new block within an existing section.

  5. Choose the section or block type, such as Collapsible Tab.

  6. Click the Collapsible Tab you just created.

  7. Under content, click the icon Connect Dynamic Source.

  8. Click Products from the menu to connect a metafield you added to the product object.

  9. Select a metafield from the list.

  10. Save your template.

Important tip:

To connect a metafield to a theme element, the metafield content type has to match the theme element content type. Otherwise, the metafield wouldn't show up in the list. For example, connecting a single-line text heading to a multi-line text metafield wouldn't work. A single-line text heading requires a single-line text metafield.