What metafields do and why they solve the size guide problem

Metafields are custom data fields you attach to products in Shopify that hold information beyond the standard product name, price, and description. They let you store size chart data separately for each product, then display that data however you want on your storefront.

The problem they solve: if you sell clothing, shoes, and accessories, each category needs a different size guide. A shirt's XL is not the same as a shoe's XL. Without metafields, you either show the same chart to everyone (wrong for most customers) or manually edit product descriptions (slow and error-prone). Metafields let you assign the right chart to each product once, then pull it into your theme automatically.

Shopify stores the metafield data in your product database. Your theme's code then retrieves it and displays it on the product page. This means you can change a size guide in one place and it updates everywhere that guide appears.

Key Takeaways

  • Metafields store custom data like size charts directly on each product, separate from the product description.
  • You create a metafield definition once in Shopify admin, then assign values to individual products.
  • Your theme's code retrieves the metafield and displays it on the product page using Liquid, Shopify's template language.
  • Different product types (shirts, shoes, accessories) can have different metafield values pointing to different size guides.
  • Metafields work best when you use a consistent naming system and store size data as JSON or plain text that your theme knows how to format.

Creating a metafield definition in Shopify admin

Start in your Shopify admin. Go to Settings, then Metafields. Click "Create definition" or "Add definition" (the button text varies by Shopify plan). You are creating a template that will explore to all your products.

Fill in the form: give the metafield a name like "Size Guide" or "Size Chart". Choose a namespace — this is a category that groups related metafields. Use something like "custom" or "product_info". The key is the internal identifier; Shopify will suggest one based on your name, like "size_guide". Leave it as suggested unless you have a reason to change it.

For the data type, choose "Single line text" if you are storing a straightforward reference like "mens_clothing_chart", or "JSON" if you want to store the actual size data (waist, inseam, chest measurements) as structured data. JSON is more powerful but requires your theme to parse it. For most stores, storing a reference to a size guide file or page is simpler.

Check "Show on product pages" so the field appears in the product editor. Save the definition. Now the metafield exists and is ready to be filled in on individual products.

Assigning metafield values to products

Open any product in your admin. Scroll down to the Metafields section — it appears below the standard product fields. You will see the metafield you just created, labeled with the name you gave it.

Enter a value. If you chose "Single line text", type something like "mens_shirts" or "womens_shoes" — a label that identifies which size guide this product uses. If you chose JSON, paste structured data like {"chest": "38-40", "waist": "32-34", "length": "29"}. Save the product.

Repeat for every product that needs a size guide. If you have hundreds of products, you can bulk-edit metafields using Shopify's CSV import or a third-party app. For smaller stores, doing it product by product takes an hour or two and ensures accuracy.

Retrieving metafields in your theme code

Your theme uses Liquid, Shopify's template language, to pull metafield data and display it. Open your theme editor: go to Sales Channels, Online Store, Themes, then click "Edit code" on your active theme.

Find the product template file — usually called product.liquid or product-template.liquid. This is the page that displays when a customer views a product. Locate the spot where you want the size guide to appear, usually near the product description or below the "Add to cart" button.

Add this Liquid code: {{ product.metafields.custom.size_guide.value }}. Replace "custom" with your namespace and "size_guide" with your metafield key. This pulls the value you entered in the admin and displays it on the page.

If you stored a reference like "mens_shirts", you will need additional code to look up the actual chart. If you stored JSON, you can loop through the data and format it as a table. Save the theme file and test on a product page.

Displaying size guides as tables or formatted blocks

A plain text value is not very useful to customers. You want a formatted table or a collapsible section. There are two approaches: store the guide as JSON and format it in Liquid, or store a reference and pull the guide from a separate page or file.

The JSON approach: store {"chest": "38-40", "waist": "32-34"} in the metafield, then use Liquid to loop through it and build an HTML table. This keeps all the data in one place but requires more code. The reference approach: store "mens_shirts_chart" in the metafield, then use Liquid to check that value and display the corresponding HTML block. This is simpler if you have only a few size guides.

For most stores, the reference approach is faster to set up. Create a section in your theme called "size-guides" that contains hardcoded HTML for each chart. In your product template, add code like: {% if product.metafields.custom.size_guide.value == "mens_shirts" %} [display mens shirt chart] {% endif %}. This way, the metafield tells your theme which chart to show, and the chart itself is clean HTML.

Using metafields for different product types

The real power of metafields appears when you have multiple product types. A shoe size guide is useless on a t-shirt. Metafields let you assign different guides to different products without changing your theme code.

Create separate metafield definitions if you want: one called "Shoe Size Guide" and one called "Clothing Size Guide". Or use a single metafield and store different values like "shoe_mens_us" or "shirt_womens_eu". Your theme code checks the value and displays the right guide.

You can also use Shopify's product type or collection tags to automate this. If all your men's shirts are tagged "mens-clothing", you can write Liquid code that says: "If the product has the mens-clothing tag, show the mens size guide." This reduces the manual work of assigning metafields to every product.

Common mistakes and how to avoid them

The most common mistake is creating a metafield but forgetting to add the Liquid code to your theme. The metafield exists in your admin, but nothing displays on the product page. Always test by viewing a product page after you add the code.

Another mistake is inconsistent naming. If you type "mens_shirts" on one product and "mens shirt" on another, your theme code will not recognize them as the same guide. Use a naming system and stick to it: all lowercase, underscores instead of spaces, no special characters.

A third mistake is storing too much data in a single metafield. If you try to store an entire size guide as plain text, it becomes hard to edit and straightforward to break. Use JSON for structured data, or store a straightforward reference and keep the actual guide in your theme or a separate file.

Finally, do not assume metafields are visible to customers by default. You must add code to your theme to display them. "Show on product pages" in the metafield definition means show in the admin editor, not on the customer-facing storefront.

Frequently Asked Questions

Can I use metafields to show different size guides on different sales channels?

Yes. Metafields are stored on the product itself, so they appear everywhere the product is sold — your online store, mobile app, Facebook shop, and so on. If you want different guides on different channels, you would need separate metafields or conditional code in each channel's theme.

What happens if I delete a metafield definition?

The data you entered on products is deleted too. If you think you might need it later, do not delete the definition. Instead, leave it in place and stop using it. You can always create a new definition with a different name if you want to reorganize.

Can customers edit metafield values, or is it admin-only?

Metafields are admin-only by default. Customers cannot see or change them unless you explicitly write code to let them. For size guides, you want them admin-only so customers see consistent, accurate information.

Do I need coding experience to use metafields?

You need basic comfort with Liquid and HTML to display metafields on your storefront. If you use a Shopify theme that already has metafield support built in, you may only need to fill in values in the admin. Check your theme's documentation to see if it supports size guides out of the box.

Can metafields store images or links, or just text?

Metafields can store URLs, so you can link to an image or PDF size guide. You can also store JSON that includes image URLs. For straightforward cases, storing a URL and using Liquid to build an image tag is the easiest approach.