Metaobjects tutorial
Metaobjects help you add and store additional structured information for your store. Metaobjects can be used in your Shopify admin for data storage or to create reusable, structured content that's displayed in your online store. Here are some examples of metaobjects and where you can use them:
- Add fabric types to your products and display them on your product pages in your online store.
- Create FAQs for your products and display them on your product pages in your online store.
- Create ambassador or influencer profiles with images and text and then display them on a page in your online store.
You can add metaobjects to your products, collections, customers, orders, and other parts of your store, directly from your Shopify admin.
If you have anOnline Store 2.0 theme, then you can connect your metaobject to your theme by creating ametaobject reference with metafields.If you're using vintage themes, or if you want to add metafield types that your theme doesn't support, then you canedit your theme codeor hire a Shopify Expert to help you. Learn more about hiringShopify Experts.
On this page
Product highlights tutorial
In this tutorial, you learn how create a metaobject for product highlights and display them on your online store.
- What you'll learn
- Step one: Create a metaobject
- Step two: Create entries
- Step three: Create a metafield definition that references the metaobject
- Step four: Connect entries to specific products
- Step five: Publish your metaobject on your store
What you'll learn
After you've finished this tutorial, you'll have accomplished the following:
- Created a metaobject for product highlights
- Created several entries for product highlights using the metaobject you created
- Created a metafield definition that references the metaobject
- Connected your entries to specific products
- Published your metaobject entries
Step one: metaobject
- From your Shopify admin, go toSettings>Custom data.
- UnderMetaobjects, clickAdd definition.
- Name your metaobject definitionProduct Highlights.
- ClickAdd fieldand select the type of content you want to display in this metaobject. Fields define the content displayed in your metaobject, and each field has its own set of options and validations.
- For this tutorial, we're building a product highlights metaobject that will display an image, the name of the product, a caption, and a description. To add the first field, selectFile.
- Configure the type and validations. Name the fieldImage, and enter a brief description.
- UnderAccess,Storefrontis automatically selected. Keep this option selected as it allows the content to be accessed and displayed by your store.
- Add the image field to your metaobject. ChooseAdd field>File.
- Name this fieldImage.
- UncheckVideosto limit this metaobject to only display images.
- Enter a description.
- ClickAddwhen done.
- Add the heading field to your metaobject. This time, chooseAdd field>Single line textas the field type. Do the following:
- Name this fieldHeading.
- CheckUse this field as display nameto use this field as the entry name in the index.
- Enter a description.
- ClickAddwhen done.
- Add the caption field to your metaobject. ClickAdd field>Single line text.Do the following:
- Name this fieldCaption.
- Enter a description.
- ClickAddwhen done.
- Add the description field to your metaobject. ClickAdd field>Multi-line text.Do the following:
- Name this fieldDescription.
- Enter a description.
- ClickAddwhen done.
- Saveyour new metaobject definition.
After your metaobject definition has been saved, you can startcreating entries.
Step two: Create entries
- From your Shopify admin, clickContent.
- ClickAdd entry.Choose theProduct Highlightsmetaobject definition to base the new entry on.
- Complete the fields for your entry:
- ClickSelect imageand choose or upload an image for this product highlight.
- Add aTitleand aDescription.
- The status is automatically set toActive.If you are not ready to use the entries, then you can change the status toDraft.
- ClickSave.
Your entry has a generatedHandle, which is a unique identifier specific to a single content entry. After you start connecting your entries to areas of your store, editing the handle isn't recommended. Learn more aboutthe impact of changing an entry handle after you have been using it in your store.
Repeat the steps above to create three more entries based on the product highlights metaobject definition.
After you have your metaobject definition and entries saved, you can create ametafield definition that references the metaobject.
Step three: Create a metafield definition that references the metaobject
- From your Shopify admin, go toSettings>Custom data.
- In theMetafieldssection, clickProducts.
- ClickAdd definition.Enter a unique name and description, and then clickSelect content type.
- ClickSelect typeand thenMetaobject.
- In theReferencesection, select the metaobject definition you want to reference. ChooseProduct Highlights.This limits the metafield product definition to only show entries related to the product highlights metaobject.
- Define whether this definition can display one entry, or a list of them. For this example, choose theList of entriesoption.
- In theAccesssection, select theStorefrontsoption.
- ClickSave.
Next, you'llconnectthe entries to the products you want to display them on.
Step four: Connect your products to the entries
From your Shopify admin, go toProducts.
Select a product that you want to display product highlights on.
Scroll down toMetafields.In this example, we want to display some of, but not all, the product highlights entries that we've created. Click the entry field next to yourProduct Highlightsmetafield。如果产品亮点并不在元fields list, then clickShow all.
ClickSelect entries.在这个步骤中,你选择条目want to display on this particular product. Choose two of your product highlights.
Return to your products page. Select a different product, and follow the previous step to assign two different product highlights entries to the product.
Next you willpublish your metaobjects on your online store.
Step five: Publishing your entries to your online store
Now that you've connected your entries to your products, it's time to display your entries on your store. This step uses the theme editor to select the blocks and sections where your metaobject entries will be linked.
After you add a section or block, you can select a metafield by clicking the connect dynamic source icon:
- From your Shopify admin, go to欧宝体育官网入口首页>Themes.
- Find the theme you want to edit, and then clickCustomize.
- Use the drop-down menu at the top of your screen to selectProducts>Default product.This loads the default product template in the theme editor.
- ClickAdd sectionin the left sidebar and chooseMultirowas the new section type.
- Click the first row of theMultirowsection.
- The settings for the first block display in the right sidebar. In your column block, you can manually select an image, insert a heading, add a caption, and add a description. You can also click each individual data source icon, and link the block setting to your desired entry.
- Click theConnect dynamic sourcenext to the block name to selectProduct Highlights.Your theme editor populates your new multirow block with your product highlights entries.
- Configure remaining blocks in theMultirowsection, or remove the unused blocks.
- ClickSaveto publish your product highlights entries.
Your entries only display on the products they're connected to and the section won't publish if a product isn't connected to entries. That means you can set up a single product template that will work for all your products.