How to manage Shopify Metafields?


Here we will take a look at how to create, update and delete your Shopify metafields. As well as we will have a small insight on how to display your metafields in your storefront. We will take a look at the metafields for Products, but you can also manage your metafields with the Excelify for:

Creating Metafields

1. Export your Products

Export Products in Shopify

2. Delete unnecessary columns

To create and manage our Metafields we will only need basic columns from exported file to identify the Product, so from exported file delete all columns except:

  • ID
  • Handle
Product identification columns Excelify

3. How to construct Metafield column.

Metafields are constructed by principle – Metafield: Namespace.Key [Metafield type], so let’s break it down:

  • Metafield: – This part allows our app to understand that this column will contain Metafield.
  • Namespace – This is a category or, how I like to say, a folder that contains your Metafields, so you can group different Metafields into these imaginary “folders”.
  • Key – The name of Metafield.
  • Metafield Type – There are 3 types of Metafields in Shopify – integer, string and json_string. Today we will be looking at string Metafields as they are the most popular.

4. Create your own Metafield column.

We will assume that we wish to display some custom product specification on our storefront so our Metafield column name will be ‘Metafield: specs.material [string].

Metafield column Excelify Shopify

5. Fill your Metafield column with values that you wish to be displayed.

Create metafield Shopify

6. Save & Import.

7. Check your new Metafields.

Sadly we cannot really see Metafields anywhere in Shopify so at the moment we can export our Products with Metafields to see in the exported file if they have stored correctly.

Updating Metafields

1. Export your Products with Metafields.

2. Delete unnecessary columns.

To update metafields we will only need Product identification columns and Metafield columns, so delete all columns except:

  • Id
  • Handle
  • Metafield: … (all your metafields columns)

3. Edit values for the Metafields you wish to update.

4. Save & Import your updated file.

5. Check your updated Metafields.

To see updated Metafields you can export your Products with Metafields just as in the #8 step.

Deleting Metafields

1. Export your Products with the Metafields.

2. Delete unnecessary columns.

To delete metafields we will only need Product identification columns and Metafield columns you wish to delete, so delete all columns except:

  • Id
  • Handle
  • Metafield: … (Metafield columns you wish to delete)

3. Delete values from Metafield column.

To delete a metafield we do need to just delete all values within its column and import this metafield empty.

4. Save & Import.

The app now deleted metafields for the products that had empty value for those metafields.

Displaying metafields

Metafields are custom fields that you can use in various places, for example if you need to store some custom information that you will use in your exported reports, but one of main metafield usage is to display this custom stored information in your store, so we will now take a quick look on how to acheive this.

1. Create your metafields.

For this please follow list points #1 – #7.

2. Go to your Themes code in your Shopify Admin.

You can locate your themes code going in your Shopify Admin -> Online Store -> Themes -> Actions -> Edit Code

Edit themes code in Shopify

3. Locate product.liquid

product.liquid contains the code for the page that displays your products.

Liquid product Code file

4. Add code to display your Metafield

Now we will add just one line of code to display this new Metafields we created in the ‘Create Metafield’ section.

Material: {{ product.metafields.specs.material }}

If you have stored your Metafield as Variant Metafield then the code you need to add will be different.

Material: {{ current_variant.metafields.specs.material}}


Shopify liquid code Metafield

5. Save and go check any product in your store.

Custom text in storepage

Good to know!