Automation guide

How to show a product metafield on a badge in Shopify

Quick answer

To show a product metafield on a Shopify badge, create a product metafield in the custom namespace (for example custom.warranty), fill in the value on each product, then add {{mtf.warranty}} to the Label Text of a text label in Nexora Product Labels & Badges. Each product's badge shows its own value, such as 2-year warranty, and the variable stays empty where no value is set.

Updated 6 min read Install free

Why put metafield data on a badge

Metafields hold the product facts that Shopify has no standard field for: warranty length, country of origin, material, roast level, battery life, pages, ABV. Shoppers often care about these details more than the product description, but they are usually buried far down the product page.

A badge brings one key fact up to the product image or right next to the title, on collection pages as well as product pages. Because the value comes from the metafield, you edit it in one place and every badge follows.

  • {{mtf.warranty}} warranty → 2-year warranty
  • Made in {{mtf.origin}} → Made in Portugal
  • {{mtf.roast}} roast → Medium roast
  • {{mtf.material}} → 100% linen

Metafield badges also suit facts that differ between products but follow one pattern. Instead of writing ten labels (1-year warranty, 2-year warranty and so on), you write one label with {{mtf.warranty}} warranty and let each product fill in its own value. Changing a warranty later is a single edit on the product.

Your options on Shopify

In Online Store 2.0 themes you can connect a metafield to a theme block through dynamic sources in the theme editor. That's great for product pages, but most themes don't offer a block on product cards in collection grids, and the styling depends on the block. See Shopify's guide to creating custom metafield definitions.

OptionProduct pageCollection cardsEffort
Theme block with a dynamic sourceYes, if your theme has a suitable blockRarelyLow
Custom Liquid codeYesYesNeeds a developer
A text label with {{mtf.KEY}}YesYesLow

Step by step: a metafield badge

  1. Create the metafield definition

    In your Shopify admin, go to Settings > Metafields and metaobjects > Products and add a definition. Use the custom namespace, a key with letters, numbers and underscores (for example warranty), and a simple type such as single line text or a number.

  2. Allow storefront access

    In the definition's access options, make sure Storefronts is selected. The app reads the value on your storefront, so it needs this access.

  3. Fill in the values

    Open each product and enter the value in the Metafields section, for example 2-year.

  4. Create a text label

    In the app, click + Add Label. On General, choose the Text type and a shape, and pick Inside Product Image or In Product Info Area.

  5. Add the variable

    On Design, set Label Text to {{mtf.warranty}} warranty. The part after mtf. must match your metafield key exactly.

  6. Choose products, activate and save

    On Display condition, set Products to the products, collections, tags or vendors that have the metafield. Click Activate, then Save.

A text label whose Label Text uses {{mtf.warranty}}

What works and what to watch

DetailWhat to know
NamespaceOnly custom. {{mtf.warranty}} reads custom.warranty
Key formatLetters, numbers and underscores, matching the key exactly
Best typesSingle line text, integer and decimal show cleanly
Other typesLists, references and measurement types are shown as their raw stored value, which may not read well
Empty valueThe variable is left empty, so the rest of your text still shows
Where it showsProduct images and cards on product, collection, search and home pages

Because an empty metafield leaves the rest of the text behind, {{mtf.warranty}} warranty would read just warranty on a product without a value. Limit the label to products that have the metafield, for example with a tag such as has-warranty under Products > Product tags.

Choosing the right metafield type

The badge shows the stored value exactly, so pick a type whose value already reads well on its own:

Product factMetafield typeLabel TextShows
Warranty lengthInteger, key warranty_years{{mtf.warranty_years}}-year warranty2-year warranty
MaterialSingle line text, key material{{mtf.material}}Organic cotton
Battery lifeInteger, key battery_hours{{mtf.battery_hours}}h battery30h battery
Alcohol contentDecimal, key abv{{mtf.abv}}% ABV5.5% ABV
A yes/no fact, such as veganBetter as a product tagVegan as static text, with Products > Product tags = veganVegan

A true or false metafield would show the word true on the badge, which is why yes/no facts work better as a tag with fixed text. Lists, measurements and references also show their raw stored value, so use single line text when you want full control over the wording.

Example: origin and roast for a coffee shop

A coffee roaster stores custom.origin (single line text) and custom.roast (single line text) on every bag.

  • Label 1: In Product Info Area, Above title, {{mtf.origin}}, small uppercase grey text. Shows ETHIOPIA, COLOMBIA and so on above each product name.
  • Label 2: Inside Product Image, Bottom-Left, a pill shape with {{mtf.roast}} roast, background colour matched to the brand.
  • Both labels use Products → Collections → Coffee, so merchandise like mugs never shows an empty badge.
A metafield value shown above the product title

Second example: two specs on one electronics badge

A headphone store keeps custom.battery_hours and custom.warranty_years (both integers) on every pair. One text label can use both variables:

  • Label Text: {{mtf.battery_hours}}h battery · {{mtf.warranty_years}}-yr warranty, which shows 30h battery · 2-yr warranty
  • In Product Info Area, Below price, aligned Left, so the specs sit under the price on cards and product pages
  • Products > Collections = Headphones, so cables and cases without these metafields never show a half-empty badge
Choose where the metafield badge sits: on the image or in the product info area

The values come from the product, not the variant, so the badge stays the same when a shopper picks a different colour.

Troubleshooting metafield badges

  • Badge shows only the static text. Check the key spelling, that the namespace is custom, that the product has a value, and that the definition allows Storefronts access.
  • Value looks like code. You're probably using a list or reference type. Use a single line text metafield for the badge.
  • Key has a hyphen. The variable only reads keys made of letters, numbers and underscores. A key like care-guide won't be picked up; create the metafield as care_guide instead.
  • Spaces and case. {{ mtf.origin }} with spaces inside the braces works, but the key must match the metafield key exactly, including upper and lower case.
  • Different language stores. You can write a translation of the surrounding text per language, for example Garantie {{mtf.warranty}} in French.
  • Need help? Message us on live chat in the app, or email [email protected].

Frequently asked questions

Which metafields can a badge show?

Product metafields in the custom namespace, using {{mtf.KEY}}. For example, {{mtf.material}} shows custom.material.

Can I use a metafield from another app's namespace?

No. Only the custom namespace is supported. You can copy the value into a custom metafield if you need it on a badge.

Why is my metafield badge blank?

Usually the product has no value, the key doesn't match exactly, or the definition doesn't allow Storefronts access.

Can I use a metafield in an image label?

No. Variables only work in Text labels.

Can a badge show a variant metafield?

No. {{mtf.KEY}} reads product metafields only, so the value stays the same for every variant of the product.

Does it work on collection pages?

Yes. Metafield badges show on product cards as well as product pages.

Keep reading

Related guides

Try Nexora Product Labels & Badges free

Every feature in these guides is included — free, on any Shopify plan.