Displaying Metaobjects in Search Results

Topic summary

A user seeks help customizing Shopify’s search.liquid code to display metaobject entries (specifically “Herb Profiles” with ~130 entries) in search results. They’re using the Trade theme and want to avoid creating individual pages or adding third-party apps.

Current Situation:

  • Shopify’s native search doesn’t automatically index metaobjects
  • A dynamic page displaying all metaobjects exists, but search bar integration is needed
  • Shopify’s Search & Discovery app doesn’t solve this issue

Proposed Solutions:

  1. Liquid modification: Loop through shop.metaobjects.herb_profiles.values and filter by search terms, then add a metaobject case to the existing search results switch statement

  2. JavaScript workaround: Preload metaobjects into JSON and filter dynamically

Technical Concerns Raised:

  • Iterating metaobjects has pagination limits (20-50 entries), potentially problematic for 130 items
  • JavaScript approach may incur SEO penalties if crawlers use search functionality

Status: The user shared their current search.liquid code structure and is working to integrate a metaobject case alongside existing product/article/page results. One responder offered direct consultation via calendar link.

Summarized with AI on November 1. AI used: claude-sonnet-4-5-20250929.

We would like to display certain metaobject pages in our search results. These metaobject entries are all under stored under one definition, “Herb Profiles”. We currently have about 130, and using metaobjects to store all of this data and content has been really great, but we don’t want to have to go and create “pages” for these as well.

We currently use the Trade theme, customised.

EDIT: I am looking for assistance in customising the search liquid code.

Hey @tesshhc

Shopify’s native search doesn’t automatically index metaobjects, which is probably why they’re not showing up in results.

Since you’re using the Trade theme, you might need to tweak your search settings. A few ways to approach this:

  1. Modify your search settings – Shopify’s default search doesn’t include metaobjects, but you can customize your theme’s search code (search.liquid or search.json) to include them.

  2. Use a dynamic collection – Instead of creating individual pages, you could create a section that pulls in all “Herb Profiles” dynamically and makes them easier to find.

  3. Try a search app – Some apps like Boost AI Search or Shopify’s Search & Discovery might be able to index metaobjects properly.

Have you tried any of these already? Let me know what you’ve tested so far!

Hello @rutvik_shop - I do understand that they don’t automatically index metaobjects, sorry I should have clarified that I’m after assistance in customising the search code. Just can’t quite make it work.

I have a page built out that displays all of our metaobjects in one place dynamically to make it easy to find, however I still want them also searchable in the search bar.

Shopify’s Search & Discovery does not help, and I’d like to avoid adding a different app.

Hi @tesshhc !

I was looking to solve the exact same problem for another client.

We do have a solution planned - and also will ask on today’s AMA if they will support this directly - but meanwhile if you also want to solve this - please reach out here: https://calendar.app.google/PGt9yqZhE7PcXC1S9

Let me know via DM (will take longer to see probably) if none of those times work for you

Hey @tesshhc ,

Got it! Since Shopify’s search doesn’t natively index metaobjects, you’ll need to modify your search.json (or search.liquid) to include them. Here’s a streamlined approach:

  1. Modify search.json (or search.liquid) – Shopify’s default search indexes products, pages, and articles, but not metaobjects. You’ll need to extend the search query to fetch metaobjects dynamically.

  2. Use Liquid to Display Metaobjects – You can loop through shop.metaobjects.herb_profiles.values and check if the title or content matches the search term.

    {% assign herbs = shop.metaobjects.herb_profiles.values %}
    {% for herb in herbs %}
    {% if herb.title contains search.terms %}


    {% endif %}
    {% endfor %}

  3. JavaScript Workaround – If the above doesn’t work, you can preload all metaobjects into a JSON file and filter them dynamically when someone searches.

@rutvik_shop (cc @tesshhc )

  1. Iterating on the metaobjects has the pagination limitations - correct? if number of entries is above 20 or even 50 - you’ll have issues with this - correct?

  2. Javascript workaround - will probably have SEO penalties if crawler uses search - correct?

Yes so I’d like to modify the search.liquid - just having trouble with the code and getting them to display still.

This is current case for search results, and obviously I’d like to get one for the herb profiles metaobjects in here..

{%- case item.object_type -%}
                      {%- when 'product' -%}
                        {%- capture product_settings -%}{%- if section.settings.product_show_vendor -%}vendor,{%- endif -%}title,price{%- endcapture -%}
                        {% render 'card-product',
                          card_product: item,
                          media_aspect_ratio: section.settings.image_ratio,
                          image_shape: section.settings.image_shape,
                          show_secondary_image: section.settings.show_secondary_image,
                          show_vendor: section.settings.show_vendor,
                          show_rating: section.settings.show_rating,
                          lazy_load: lazy_load,
                          skip_styles: skip_card_product_styles
                        %}
                        {%- assign skip_card_product_styles = true -%}
                      {%- when 'article' -%}
                        {% render 'article-card',
                          article: item,
                          show_image: true,
                          show_date: section.settings.article_show_date,
                          show_author: section.settings.article_show_author,
                          show_badge: true,
                          media_aspect_ratio: 1,
                          lazy_load: lazy_load
                        %}
                      {%- when 'page' -%}
                        
                          

                            

                              

                                ### 
                                  
                                    {{ item.title | truncate: 50 | escape }}
                                  
                                
                              

                              
                                
                                  {{- 'templates.search.page' | t -}}
                                
                              

                            

                          

                        

                    {%- endcase -%}