With metafields, you can store extra product information, like a frame's height, and show it automatically in your theme's blocks. In this guide, you'll add a Frame height metafield and display it on product pages.
There are three steps:
- Create a metafield definition
- Add a value to each product
- Connect the metafield to a block in the theme editor
Step 1: Create a metafield definition
- In your Shopify admin, go to Settings > Metafields and metaobjects.
- Click Products, then Add definition.
- Enter a Name (for example, Frame height). Shopify generates the Namespace and key for you, and you can edit it if needed.
- Optional: Click Add description to leave a note for your staff.
- Click Select type and choose Dimension. For other kinds of information, choose a different type, such as single-line text, URL or file. See Shopify's full list of metafield types.
- Optional: Set Validation rules, such as a minimum or maximum value.
- Click Save.
Tip: You can also create a definition from any product page. Scroll to the Metafields section and click Add definition.
Step 2: Add a value to your products
- Go to Products and open a product.
- Scroll to the Metafields section. If Frame height isn't listed, click View all.
- Click the Frame height row, enter the height, and choose a unit (for example, cm).
- Click Save. Repeat for each product.
Step 3: Connect the metafield in the theme editor
- Go to Online Store > Themes and click Edit theme.
- Open a product template from the page selector at the top. (See Creating additional templates with the theme editor.)
- In the product information section, click Add block and choose Text. (See Working with page blocks.)
- Select the new block, click its text setting, then click the Connect dynamic source icon (or Insert dynamic source).
- Choose Frame height, then click Insert.
- Optional: Add text before it (for example, Height:) and drag the block where you want it, such as below the product title.
- Click Save.
The block now shows each product's own height. If a product has no value, nothing appears in that spot.