What is a metafield?

Modified on Mon, 25 Oct 2021 at 11:05 AM

The Metafields object is a Shopify feature that provides users an extra space to store the additional data used in custom apps and themes. The Metafields object is used for backend data management only and doesn’t affect neither the storefront nor the functionality of a website by default. You can learn more about the metafields object here.
Our app is a powerful tool to make metafields management process easier, faster and more efficient, but it doesn’t affect the functionality and/or storefront of your website neither.
You can use metafields to store custom attributes for your products (or any other resource type), however, you have to customize your theme in order to display them on the storefront. 
Shopify's got a special markup language called Shopify Liquid that serves this purpose.


When it comes to metafields usage in terms of custom Liquid code snippets, all you need to know is that the metafields object consists of three main components: 
 1) namespace,
 2) key, 
 3) value. 
Namespaces are used to group different metafields (something like a folder or a logical container), keys are unique identifiers to reference the information stored in metafields, and values will contain the the data itself.


In order to display a metafield on the storefront with Liquid, one should use a certain pattern: 
{{ product.metafields.namespace.key.value }}


That’s a really important part of custom functionality development as a slightest mismatch between namespace and key combinations used by custom Liquid snippet and your actual metafields will prevent them from being displayed on the product page. Just a friendly reminder :)

With this said, let’s assume you’ve created a metafield to store additional descriptions for products: namespace will be “custom_design” and the key — “short_description". 
Don't know how to create a metafield yet? Don't worry, we'll figure it out right now! Actually, creating a metafield is pretty easy. First of all, you may want to click the "Create metafield" button:
to add new metafield section to the editor:

Next, you may want to fill in all the required fields: 

1) type, 

2) namespace, 

3) key  

4) value (the input field might look different depending on what value type you've selected)

And hit the "Save" button (5) when you're done:




Now that our short description metafield is created, you need to add the following custom code line to the product page template file: 
{{ product.metafields.custom_design.short_description.value }}

as shown in this official Shopify tutorial


Luckily, we’ve got a detailed step-by-step tutorial showing how to add and manage custom product attributes using metafields, some custom Shopify Liquid code and our awesome app.
That’s a pretty nice point to start with metafields usage, we believe :)

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article