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 warrantyMade 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.
| Option | Product page | Collection cards | Effort |
|---|---|---|---|
| Theme block with a dynamic source | Yes, if your theme has a suitable block | Rarely | Low |
| Custom Liquid code | Yes | Yes | Needs a developer |
A text label with {{mtf.KEY}} | Yes | Yes | Low |
Step by step: a metafield badge
Metafield variables such as {{mtf.warranty}}, and metafield conditions, are part of the Pro plan ($6.99 every 30 days or $59 a year, with a 7-day free trial).
- Create the metafield definition
In your Shopify admin, go to Settings > Metafields and metaobjects > Products and add a definition. Use the
customnamespace, a key with letters, numbers and underscores (for examplewarranty), and a simple type such as single line text or a number. - 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.
- Fill in the values
Open each product and enter the value in the Metafields section, for example
2-year. - 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.
- Add the variable
On Design, set Label Text to
{{mtf.warranty}} warranty. The part aftermtf.must match your metafield key exactly. - Choose products, activate and save
On Display condition, set Products to the products, collections, tags or vendors that have the metafield, or to Products matching conditions with a Product metafield rule. Click Activate, then Save.
What works and what to watch
| Detail | What to know |
|---|---|
| Namespace | Only custom. {{mtf.warranty}} reads custom.warranty |
| Key format | Letters, numbers and underscores, matching the key exactly |
| Best types | Single line text, integer and decimal show cleanly |
| Other types | Lists, references and measurement types are shown as their raw stored value, which may not read well |
| Empty value | With Hide the label when a variable has no value ticked (default for new labels), the label is hidden on that product. Unticked, the variable is left empty and the rest of your text still shows |
| Where it shows | Product images and cards on product, collection, search and home pages |
If Hide the label when a variable has no value is unticked, {{mtf.warranty}} warranty reads just warranty on a product without a value. Keep the option ticked, or limit the label to products that have the metafield with Products > Products matching conditions > Product metafield custom.warranty has a value.
Showing a badge based on a metafield
{{mtf.KEY}} prints a value. Sometimes you don't want to print it, only to decide which products get a badge: a Vegan badge on products whose custom.diet is vegan, or a 2-year warranty image on products where a warranty metafield has a value. For that, use a condition instead of a variable.
- Choose Products matching conditions
On Display condition, set Products to Products matching conditions. This is available on manual labels.
- Add a Product metafield rule
Pick Product metafield, then choose a definition or type
namespace.key. Operators are has a value, is empty, is equal to, is not equal to and contains. - Combine if needed
Add more rules, such as Collection is in Coffee, and choose All conditions or Any condition.
- Save and wait a moment
After you save, the app works out which products match. That can take up to a few minutes for large stores, and the list is kept up to date as products change.
{{mtf.KEY}} variable | Product metafield condition | |
|---|---|---|
| What it does | Prints the value in the label text | Decides which products show the label |
| Namespaces | custom only | Any namespace, including other apps' |
| Storefront access | Needed | Not needed |
| Label types | Text and Stock bar | All, on manual labels |
If a metafield condition matches a very large number of products, the editor may ask you to narrow it, for example by adding a collection rule.
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 fact | Metafield type | Label Text | Shows |
|---|---|---|---|
| Warranty length | Integer, key warranty_years | {{mtf.warranty_years}}-year warranty | 2-year warranty |
| Material | Single line text, key material | {{mtf.material}} | Organic cotton |
| Battery life | Integer, key battery_hours | {{mtf.battery_hours}}h battery | 30h battery |
| Alcohol content | Decimal, key abv | {{mtf.abv}}% ABV | 5.5% ABV |
| A yes/no fact, such as vegan | Better as a product tag | Vegan as static text, with Products > Product tags = vegan | Vegan |
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. ShowsETHIOPIA,COLOMBIAand 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.
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 shows30h 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
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-guidewon't be picked up; create the metafield ascare_guideinstead. - 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?
Not as text: the {{mtf.KEY}} variable reads the custom namespace only, so copy the value into a custom metafield if you need to print it. For deciding which products get a badge, the Product metafield condition works with any namespace.
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?
Not as a variable: variables only work in Text labels and the text of Stock bar labels. You can still show an image label only on products with a certain metafield value, using the Product metafield condition.
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.



