Connecting and displaying metaobjects

You can use the theme editor to display the content of metaobjects in your theme in any of the following ways:

  • connect metaobjects to blocks
  • connect metaobject fields to block settings and theme settings that support dynamic sources
  • edit your theme code to add metaobjects

For step-by-step instructions, learn how to create a Product highlight metaobject definition.

Compatibility considerations for connecting and displaying metaobjects

Review the following considerations for connecting and displaying metaobjects on your online store:

  • To connect a metaobject to a block or setting in the theme editor, the metaobject's metafield types in the metaobject have to match the type of content in the block. You can connect any compatible types to the corresponding area in your theme settings.
  • To connect a metaobject, the metaobject needs to include a corresponding metafield type, such as a Single line text metafield to connect to the Heading or Caption block settings of a Column block.
  • You need to ensure the metaobject has Storefronts access to display it on your online store. Learn more about options for custom data.
  • If the metaobject field is a list, then the theme editor will automatically add each entry in the list to the block setting.

Connect metaobjects and metaobject references to blocks

You can connect a metaobject that you created, or metafield that is a metaobject reference for that related template, such as connecting a product's category metafields to a product template, directly to any blocks that support metaobject connections. Connecting a metaobject to a block automatically maps compatible fields to the block's settings.

You can only connect metaobjects or metaobject references to a block. For example, you sell books and added the following product metafields to your products:

  • shipping dimensions using the Single line text metafield type
  • number of pages using the Integer metafield type
  • book cover type using a category metafield
  • author using a metaobject reference type.

On your product template in the theme editor, you can connect the book cover type or author product metafields, but not the shipping dimensions or number of pages metafields.

You can only connect metafields from areas in your admin with metaobject reference types to matching templates in your theme. For example, if you're customizing your Home Page, then you can connect any custom metaobjects from the Content > Metaobjects section of your Shopify admin, but you can't connect any metafields with metaobject references from your product metafields.

Steps:

  1. From your Shopify admin, go to Online Store > Themes.

  2. Click Customize next to the theme that you want to edit.

  3. Optional: If you want to customize a template other than the Home page, then select the template that you want to customize from the drop-down menu.

  4. Click the block that you want to connect a metaobject or metaobject reference to.

  5. Click the connect dynamic source icon next to the block.

  6. Connect dynamic source icon and then connect a metaobject or metaobject reference from any of the following sources, if available:

    • In the From this template section, click Template > Product, and then select a compatible metaobject reference type, such as a category metafield.
    • In the From your store section, click Metaobjects, Market or Brand, and then select a compatible metaobject or metaobject reference.
  7. Click Save.

Connect metaobject fields to settings that support dynamic sources

You can connect a metaobject's field directly to a compatible block setting or theme setting.

Steps:

  1. From your Shopify admin, go to Online Store > Themes.

  2. Click Customize next to the theme that you want to edit.

  3. Optional: If you want to customize a template other than the home page, then select the template that you want to customize from the drop-down menu.

  4. Optional: If you want to connect a dynamic source to a theme setting, then click the cog wheel icon.

  5. Click the setting that you want to connect a metaobject or metaobject reference to.

  6. Click the connect dynamic source icon next to the setting.

  7. Connect dynamic source icon and then connect a metaobject or metaobject reference from any of the following sources, if available:

    • In the From this template section, click Template > Product, and then select a compatible metaobject reference type, such as a category metafield.
    • In the From your store section, click Metaobjects, Market or Brand, and then select a compatible metaobject or metaobject reference.
  8. Select the metaobject's field that you want to connect.

  9. Click Save.

Editing your theme code to add metaobjects

You can use your metaobject entries anywhere on your online store using Liquid, Shopify's templating language. You can connect metaobject entries to pages, blogs, homepage, and collection templates.

These entries might be referenced through metafields or accessed directly and can be implemented through a metaobject or metaobject list setting.

If you want to edit your theme code to display metaobjects on your online store, then you can use Liquid to reference metafields in your theme templates.

Learn more about hiring a Shopify Partner and using custom data for developers.

Can’t find the answers you’re looking for? We’re here to help.