Metafields: Comprehensive Guide to Customizing Your Shopify Store

Metafields: Comprehensive Guide to Customizing Your Shopify Store

·

3 min read

Purpose of Metafields

Metafields help you to customize the functionality and appearance of your Shopify store by letting you save specialized information that isn't usually captured in the Shopify admin. You can use metafields for internal tracking, or to display specialized information on your online store in a variety of ways.

Difference between Metaobjects and Metafields

Shopify offers a feature called Metafields, which enables you to add personalized fields to different objects within your store's data model. These objects may include products, variants, customers, orders, etc. Metaobject refers to objects or entities in the Shopify system that oversee or regulate metadata.

Metaobjects help you add and store additional structured information for your store. Metaobjects can be used internally in your Shopify admin and you can also choose to display them in your online store.

Learn more about how to use metaobjects.

Use of Metafields for SEO

A meta field increases the data elements of your product items, customers, or transactions, which is beneficial for your SEO. For example, you might have used metafields in the past to add particular care instructions for your buyers on the product

Use metafields to change the way a store's pages appear in search engine results.

Maximum number of Metafields

On Shopify you can have 200 metafields for each resource type. The number of metafields do not based on your Shopify subscription. This means that each subscription receives the same number of metafields.

Resources that can have metafields

Example of Metafield definition

For example, a metafield definition for product expiration date might have the key of products. expiration_date , a value of Date , and a description of Enter the date in the format YYYY/MM/DD . Its validations might specify that only date values between 2021/07/01 and 2025/12/31 are valid.

Parts of a metafield definition

How do I access Metafields?

Metafields are also accessible as Liquid objects in themes, by wrapping the full definition in curly brackets, like a typical Liquid object, along with value.

For example if we add {{ ` product.metafields.my_fields.instructions.value }} to a main-product.liquid section, we can output the instructions value for the current product.

Expanding further, Liquid filters can also be applied to metafields, which is very helpful when the type of metafield you want to include is a URL, or an image.

For example if we have a metafield which is an image, we would need to apply image filters so that the assigned image will render correctly. Once these filters are applied, the full object would appear like:

{{ product.metafields.my_fields.custom_image.value | image_url: width: 500 | image_tag }}

Having access to metafields within Liquid opens up a deeper level of flexibility to display custom rich content on storefronts.

Work with Metafields when building Shopify themes

Conclusions

Metafields offers creative and interesting ways that empower merchants to personalize each page of their storefront that unlock new functionality and opportunities for merchants. Instead of hunting for that elusive Shopify theme that covers it all, Metafields gives you the mean to craft that unique Shopify product description that will sell.