/

December 30, 2024

Implementing Metaobject and Metaobject_list Schema in Shopify

 

Metaobjects help you add and store additional structured information for your store. For example, you can store information for a product, such as features, specifications, and size charts.

In Shopify Winter Edition 2025, two new schema types, Metaobject and Metaobject_list have been introduced. These make it easier to work with metaobjects, helping you manage and use structured data more simply and efficiently in Shopify

Let’s see how these can be fully used.

 

Creating Metaobjects in Shopify

1. Add Metaobject Definitions

To access Shopify Admin: To access the admin interface, sign in to your Shopify account and navigate to your Shopify admin dashboard.

Navigate to Settings: On the left hand side of the dashboard, click on the “Settings” tab.

 

Click on “Custom data.

Click Add Definition and name your metaobject (e.g., Image With Text ).

 

Add fields to define the content you want to display (e.g., text, images, etc.).

Save your metaobject definition.

 

Add Metaobject Entries:

Go to Content > Metaobjects in your Shopify admin.

Select the metaobject definition you created and click Add entry.

Fill in the fields with the relevant content and set the status to “Active.”

Save your entry.

Now let’s understand how to define the metaobject and metaobject_list schemas and how they are used in Liquid code.

In your Shopify admin, go to Online Store > Themes > Edit Code.

Locate the Sections folder.

Click Add a new section.

Enter the name of the section.

1. Schema Definition

Metaobject:

A metaobject allows you to select a single metaobject entry.

{
“type”: “metaobject”,
“id”: “my_material_setting”,
“label”: “Single Material”,
“metaobject_type”: “image_with_text”
}

metaobject_type: The specific metaobject definition to use. ( It means you need to write the type of the metaobject you created here.)

 

Metaobject List:

A metaobject allows you to select a multiple metaobject entries.

{
“type”: “metaobject_list”,
“id”: “my_material_list_setting”,
“label”: “Materials List”,
“metaobject_type”: “image_with_text”,
“limit”: 12
}

Similar properties as metaobject, but supports multiple entries.

 

2. Using in Liquid code

You can access and display metaobject and metaobject_list data like this.

Using Metaobject Schema in liquid

{% if section.settings.my_material_setting != blank %}
{%- assign single_material = section.settings.my_material_setting -%}
<div class=”material-section”>
<div class=”material-header”>
<h2>{{ single_material.title.value }}</h2>
</div>
<div class=”material-body”>
{% assign gallery = single_material.image.value %}
{% for image in gallery %}
<div class=”image-container”>
{% assign image_url = image | img_url: ‘500x’ %}
<img src=”{{ image_url }}” >
</div>
{% endfor %}
<div class=”material-details”>
{% if single_material.description != blank %}
<div class=”material-description”>
{{ single_material.description }}
</div>
{% endif %}
</div>
</div>
</div>
{% endif %}

 

Using Metaobject_list Schema in liquid

{% if section.settings.my_material_list_setting != blank %}
{% for material in section.settings.my_material_list_setting %}
<div class=”material-section”>
<div class=”material-header”>
<h2>{{ material.title.value }}</h2>
</div>
<div class=”material-body”>
{% assign gallery = material.image.value %}
{% for image in gallery %}
<div class=”image-container”>
{% assign image_url = image | img_url: ‘500x’ %}
<img src=”{{ image_url }}”>
</div>
{% endfor %}<div class=”material-details”>
{% if material.description != blank %}
<div class=”material-description”>
{{ material.description }}
</div>
{% endif %}
</div>
</div>
</div>
{% endfor %}
{% endif %}

 

Go to Online Store > Customize.

Add the name you gave to your section. We named the section Custom MetaObject Section, so we added that section.

 

Feature Metaobject Metaobject_list
Entry Type Single entry Multiple entries
Liquid Access Direct reference Loop through entries

 

Now your metaobject and metaobject_list data will display dynamically on your Shopify store!

 

From the same category