Shopify

Elevate Your Shopify Collection Carousels: Custom Labels Without Renaming (The Metafield Advantage)

Hey store owners! Ever found yourself staring at a beautifully designed collection carousel, only to notice that all your collection names start with the same repetitive prefix? Like "Men's T-Shirts," "Men's Jeans," "Men's Hoodies"? It looks a bit clunky, right?

That's exactly the challenge MEZ_MUS brought up in a recent community discussion, and it's a super common one. They wanted to display shorter, cleaner labels (think "T-Shirts" instead of "Men's T-Shirts") in their carousel, but without actually renaming the collections. Why? Because those full collection names are crucial for SEO, URLs, and consistent navigation across your site. Renaming them just for a carousel is a big no-no.

The good news? The community rallied with some fantastic solutions leveraging Shopify's powerful metafields and a touch of Liquid code. As your Shopify migration experts at Shopping Cart Mover, we're here to dive into how you can achieve this polished look on your Shopify store.

Shopify Liquid code for displaying custom collection labels in a carousel
Shopify Liquid code for displaying custom collection labels in a carousel

The Power of Metafields: Custom Display Names

The overwhelming consensus from experts like Zanye, Mustafa_Ali, DanielAnderson, and many others was to use a custom.display_name metafield. MEZ_MUS had already created one, which is a great start!

Why metafields? Metafields allow you to add custom fields to almost anything in Shopify – products, collections, customers, pages, etc. This means you can store extra information (like a shorter display name) without altering the core data (your actual collection title). It's clean, scalable, and doesn't mess with your SEO. This approach keeps your primary collection titles intact for search engines and internal linking, while providing a flexible way to present information differently in specific contexts, like a carousel.

Step-by-Step: Wiring Up Your Metafield for Collection Carousels

Here's how you can implement this robust solution:

  1. Create or Verify Your Metafield:
    • Go to your Shopify admin > Settings > Custom data.
    • Select "Collections" to add a new metafield definition.
    • Click "Add definition" (or edit an existing one if you already have custom.display_name).
    • Name: Display Name
    • Namespace and key: custom.display_name (this is automatically generated if you name it "Display Name").
    • Type: Select "Single line text". This is crucial, as other types like "Rich text" require different Liquid handling and can introduce unwanted HTML tags if not properly filtered.
    • Save your metafield definition.
  2. Populate Your Metafield:
    • Navigate to "Products" > "Collections" in your Shopify admin.
    • Open each collection you want to customize.
    • Scroll down to the "Metafields" section.
    • You'll see your new Display Name metafield. Enter the shorter, custom label you want to appear in the carousel (e.g., "T-Shirts" for "Men's T-Shirts").
    • Save the collection. Repeat for all relevant collections.
  3. Edit Your Theme Code (Liquid Implementation):
    • Go to "Online Store" > "Themes".
    • Find your current theme, click "Actions", then "Edit code".
    • You'll need to locate the Liquid file responsible for rendering your collection carousel. This is often in a section file (e.g., sections/collection-list.liquid, sections/featured-collections.liquid) or a snippet (e.g., snippets/collection-card.liquid). Use the search bar in the code editor to look for phrases like collection.title within loops that iterate over collections (e.g., for collection in collection_list).
    • Once found, replace the direct {{ collection.title }} reference with the following Liquid code, as suggested by Mustafa_Ali:
      {%- assign display_title = collection.metafields.custom.display_name.value | default: collection.title -%}
    • Then, wherever the carousel currently outputs {{ collection.title }}, replace it with {{ display_title }}.
    • The default filter is key here: if a collection doesn't have a custom display name set in the metafield, it will gracefully fall back to showing the normal collection.title. This allows you to update collections gradually without breaking your carousel.
    • Save your changes.
  4. Clear Theme Cache:
    • As Joshua827 noted, sometimes theme changes, especially those involving metafields, require clearing the theme cache to reflect immediately. While Shopify often handles this automatically, if you don't see your changes, a quick cache clear (or even just previewing the theme in a different browser/incognito mode) can help.

Considering Liquid-Only Alternatives (with Caution)

While the metafield approach is superior for flexibility and control, some community members like Ploqo and mastroke also proposed Liquid-only solutions for specific scenarios, particularly if all your collection names consistently start with the same prefix (e.g., "Men's ").

Automatic Stripping with remove_first:

{{ collection.title | remove_first: "Men's " }}

This will remove the first occurrence of "Men's " from the title. However, as MayraApps wisely pointed out, this can be problematic:

  • remove (without `_first`) removes all occurrences, not just the prefix.
  • If a collection title doesn't start with "Men's ", it will remain unchanged.
  • Be mindful of apostrophe types (straight ' vs. curly ’).

More Robust Stripping (MayraApps's improved version):

{%- liquid
  assign label = collection.metafields.custom.display_name.value | default: collection.title
  assign prefix = label | slice: 0, 6
  if prefix == "Men's " or prefix == "Men’s "
    assign label = label | slice: 6, 200
  endif
-%}
{{ label }}

This snippet is much safer. It first tries to use the metafield (if set), then defaults to the collection title. Only then does it check if the title *actually* starts with "Men's " (handling both apostrophe types) before stripping it. This combines the flexibility of metafields with an intelligent auto-strip fallback.

Protecting Your Customizations During Theme Updates

A critical point raised by Mustafa_Ali and MayraApps is the vulnerability of theme code edits to updates. If you're using a Shopify-managed theme that receives automatic updates, direct edits to core files can be overwritten.

  • Metafield values are safe: Your custom.display_name metafield values are stored in Shopify's database, separate from theme files, and will not be affected by theme updates.
  • Theme code is vulnerable: If you've inserted the Liquid code directly into a file that gets replaced during an update, your changes could be lost.
  • Best practices:
    • Work on a duplicate theme: Always duplicate your live theme and make edits on the unpublished copy. Test thoroughly before publishing.
    • Document your changes: Keep a detailed record of which files you've edited and what changes you made. This allows for quick re-application if an update wipes them.
    • Utilize Online Store 2.0 (OS 2.0) features: Newer OS 2.0 themes handle customizations better, often allowing changes within sections and blocks that are less prone to being overwritten. If possible, make your edits within a custom section or block.

Final Thoughts and Benefits

By implementing a custom display name metafield, you gain significant advantages:

  • Improved UX: Cleaner, more concise labels in carousels enhance the user experience.
  • SEO Integrity: Your full collection names remain untouched for search engines and internal linking.
  • Flexibility: Complete control over how each collection is labeled in specific contexts.
  • Scalability: Easily manage custom labels across a large number of collections.

This seemingly small customization can make a big difference in the professionalism and usability of your Shopify store. If you're tackling a Shopify migration or looking to optimize your existing store's development and integrations, don't hesitate to reach out to the experts at Shopping Cart Mover for seamless, professional assistance.

Share:

Use cases

Explore use cases

Agencies, store owners, enterprise — find the migration path that fits.

Explore use cases