in

Add a Custom Product Badge to Your Store with Shopify Liquid Code

Want to spotlight a sale, bestseller, or limited-edition item? Shopify Liquid product badge code lets you show custom labels on the products that meet your criteria. Learn where to add the code, style badges to match your store, and test them across products and devices for a polished, accessible result.

A custom product badge is a simple way to highlight sale items, bestsellers, new arrivals, or other products you want shoppers to notice. With Shopify Liquid product badge code, you can add a badge to your product cards and tailor its text and appearance to match your store.

In this guide, you’ll learn how to add a custom product badge using Shopify Liquid and where to place the code in your theme. With a few small edits, you can make important products stand out and create a shopping experience that feels more personal to your brand.

Add a Custom Product Badge with Shopify Liquid Product Badge Code

A badge works best when it tells shoppers something specific at a glance. Before adding code, decide what the label should say, which products should receive it, and where your theme builds the product display.

Those choices shape both the Liquid condition and the file you’ll edit. The steps below use a product tag as a simple, easy-to-manage way to control which items get a badge.

Choose the Badge Text and Product Conditions

Start by choosing a short label that fits comfortably on a product image or card. “Staff pick,” “Just in,” and “Limited stock” each communicate a different reason to pay attention, so match the wording to the product and your store’s tone.

Next, decide how you’ll identify eligible products. A tag is a practical option because you can add or remove it from a product’s admin page without changing the code. For example, add the tag staff-pick to each item that should display the “Staff pick” badge.

  • Use a consistent tag spelling and capitalization.
  • Choose one clear condition for each badge.
  • Keep the label concise so it remains readable on mobile screens.

Find the Right Shopify Theme File

Once the rule is clear, locate the file that renders the product card or product page. The correct location depends on your theme, so use the theme’s code editor search rather than assuming every store uses the same file names.

In Shopify admin, go to Online Store > Themes, open the actions menu for your theme, and select Edit code. Look in files such as snippets/card-product.liquid for collection cards, or sections/main-product.liquid for the product page. Make a copy of your theme first, then find the product title, image, or price markup as an insertion point.

Add Shopify Liquid Product Badge Code to Your Product Template

With the right file open, add the condition near the product image or title so shoppers can spot the label quickly. The example below supports common product-card and product-page variable names; check your file and adjust the variable if your theme uses a different one.

This Shopify Liquid product badge code displays a badge only when the product has the chosen tag:

{% assign badgeproduct = cardproduct | default: product %}
{% if badgeproduct and badgeproduct.tags contains 'staff-pick' %}
  <span class="custom-product-badge">Staff pick</span>
{% endif %}

Save the file and preview a tagged product, then check an untagged one to confirm the condition works. Add styling for .custom-product-badge in your theme’s stylesheet to control its color, spacing, and position without changing the Liquid logic.

Style and Position Your Custom Product Badge

Once the badge appears on the right products, a little design work can make it feel like part of your theme rather than an afterthought. Consider how it will look against different product photos, screen sizes, and types of product information.

Start with appearance, then check how the label behaves on smaller screens and how your Liquid condition handles other products in your catalog.

Create a Badge Style That Fits Your Store

A badge should be noticeable without competing with the product itself. Use your theme’s existing colors and type styles as a guide, and choose a background and text color with strong contrast.

Add a rule for .custom-product-badge to your theme’s stylesheet. For example, a small amount of padding, rounded corners, and a clear font weight can make the label easy to scan. Adjust the values to suit your design:

.custom-product-badge {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  border-radius: 0.25rem;
  background: #222;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

If the badge sits over an image, position it within the image wrapper and give the wrapper position: relative. Keep enough space from the image edges so the label doesn’t cover important product details.

Placement and legibility matter just as much on narrow screens, where product cards have less room. A quick mobile preview can reveal wrapping or overlap that isn’t obvious in the desktop editor.

Make the Badge Responsive and Accessible

On mobile, long labels can crowd the image or obscure the product. Keep the text concise, and use a media query to slightly reduce padding or font size when the available space is limited.

Make sure the badge remains readable against every image it may appear on; a solid background is often more reliable than placing text directly over a photo. Use meaningful visible wording, and don’t rely on color alone to explain what the label means.

Because this badge is informational rather than interactive, it generally shouldn’t look like a button. If you change it into a link, ensure it can be reached and activated by keyboard, with a visible focus style.

With the visual details in place, you can extend the condition to suit different product groups. The same Shopify Liquid product badge code can check product properties instead of relying on a single tag.

Adjust Shopify Liquid Product Badge Code for Different Product Types

For a product-type-specific label, replace the tag check with a condition based on the product’s type. For instance, a theme using cardproduct could display a “New furniture” badge when card

product.type == 'Furniture'.

Keep the variable consistent with the template you’re editing: collection-card files may use cardproduct, while product pages commonly use product. If you add several badge rules, decide which label takes priority so a product doesn’t receive overlapping badges.

After changing the condition, preview products that should match and products that should not. This simple check helps confirm both the Liquid logic and the badge’s position across your store.

Test and Maintain Your Product Badge

A badge that looks right on one product can behave differently on another. A quick, deliberate check now can catch display problems before shoppers encounter them and make future updates easier.

Work through a few representative products, then check the code and styling if anything looks off. This final pass helps keep your label useful as your catalog and theme change.

Start by checking both the badge’s condition and its appearance in the places shoppers browse. The following checks can reveal issues that a single desktop preview might miss.

Preview the Badge Across Products and Devices

Preview at least one product that should show the label and one that should not. If you use badges in both collection cards and product pages, inspect both templates; they may render products differently.

Also test a product with a long title, a busy image, or multiple product labels. Confirm the badge doesn’t cover important details, wrap awkwardly, or collide with other elements. Use your theme preview to check a narrow mobile layout as well as desktop.

  • Check tagged and untagged products.
  • Review collection pages and individual product pages.
  • Look for clipping, overlap, and readable contrast on different images.

If the label appears where it shouldn’t—or disappears where expected—the issue may be in the Liquid condition rather than the design. A few targeted checks can help identify the cause.

Troubleshoot Common Liquid and Styling Issues

When a badge is missing, first confirm that the product variable in the condition matches the file you edited. A collection-card template may use cardproduct, while a product page often uses product; a mismatched variable can prevent the condition from evaluating as intended.

Next, check that the product has the exact tag your Shopify Liquid product badge code expects, and verify that the edited file is the one used by the relevant template. If the badge exists but is hidden, inspect the browser’s rendered styles for rules affecting display, positioning, overflow, or z-index. A parent element may also need position: relative for an absolutely positioned badge.

Once everything works, make the implementation straightforward to revisit. Small organizational choices help prevent future edits from breaking the display.

Keep Your Shopify Liquid Product Badge Code Easy to Update

Add a brief Liquid comment explaining the badge rule, especially if the condition is more complex than a single tag check. Keep the badge’s CSS in your theme stylesheet rather than scattering duplicate rules across files, and use a distinctive class name to reduce conflicts with existing theme styles.

If you create several labels, document what triggers each one and decide how competing conditions should behave. After theme updates or changes to product-card layouts, repeat the preview checks above. That simple maintenance habit helps your badge stay consistent, readable, and easy to manage.

Make Your Best Products Stand Out with a Badge That Fits Your Store

A custom product badge can help shoppers spot what matters, whether you’re highlighting a staff pick, a new arrival, or another product group. With Shopify Liquid product badge code, you can control which items display a label and tailor its look to your store.

The best results come from pairing a clear product condition with thoughtful styling. Keep the badge readable and responsive, then preview it across relevant templates, products, and screen sizes to catch display issues early.

Once your badge is in place, a little documentation and occasional testing will make it easier to maintain as your catalog and theme evolve. Start with one useful label, see how it works for shoppers, and build from there.

Leave a Reply

Your email address will not be published. Required fields are marked *

      Written by Maeve Rodriguez

      Maeve is a Business Content Writer and Front-End Developer. She's a versatile professional with a talent for captivating writing and eye-catching design.