How can I prevent my website pages from appearing in search results?

Topic summary

A user running a Shopify store wants to hide certain pages from appearing in both site search results and Google search. They’re using the Label theme and have attempted code solutions from other sources without success.

Solutions Provided:

  • CSS approach: Add display:none styling to .st-filterable-col-span-3 in theme.css.liquid to hide pages from site search results
  • Robots meta tag: Insert noindex meta tags in theme.liquid’s section to prevent Google indexing, using conditional logic based on product handles
  • Search template modification: Replace specific code blocks in the main-search.liquid file to filter out non-product results

Technical Details:

  • Multiple users shared code snippets for the Label and Dawn themes
  • Solutions involve editing theme.liquid, theme.css.liquid, and main-search.liquid files
  • One approach filters search results to show only products by modifying the search template logic
  • Another uses conditional statements to exclude specific product handles from indexing

Current Status:

The original poster reported that initial code attempts caused errors appearing at the top of the screen. A second user with the Dawn theme has the same issue and shared their code seeking help. The thread remains open with multiple solution attempts provided but unclear final resolution.

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

Hi, I am trying to hide pages from showing up in search results on my site and on google. I have found some code from other articles but cannot seem to get it to work.Attached is a photo showing the search results with the pages showing up. I am using the theme label and my site url is https://brandonthorne.com/

<input type=hidden name=type value="product,article">
1 Like

Which theme are you using?

Hi There,

Thanks for reaching out! Which theme are you using?

@Jay Hi, I am using the theme label

Thank you for your response. Are you able to share the code from the search results section? I don’t know this theme, some of the themes allow you to choose what to show on the results page from the customize theme editor.

Hello @bthorne1 :waving_hand:

You can go to Shopify Admin, Themes, Edit code, open file theme.css.liquid (or similar) and add this code snippet at the bottom

#facets-filterable .lg:col-span-3 {
    display: none;
}

The result

Hope that helps!

Hello @bthorne1 ,

It’s flareAI - your Fully Automated Free Sales Machine here. We are helping Shopify merchants provide solutions for the last few years in Shopify Community.

If helpful, please consider Like and Accept solution.

You can read this blog for more details on hiding pages from Shopify search

To block Google from indexing your page, you can use what’s called a robots HTML tag with the noindex content.

You can hide the pages from search engines by customizing the section of your store’s theme.liquid layout file. You need to include some code to noindex particular pages.

Steps required:

  1. From your Shopify admin, go to Online Store > Themes
  2. Click on your active theme then click Edit code
  3. Edit the theme.liquid layout file
  4. To exclude the product pages, paste the following code in the section:

{% if handle contains ‘product-handle-you-want-to-exclude’ %}

{% endif %}

Replace product-handle-you-want-to-exclude with the product handle you want to exclude.

  1. Click Save

Ecommerce on Google Search is greater than all paid channels and social media combined. Make sure you are getting good amount of organic traffic and sales. You will get organic orders only if your products are indexed on Google. For this you have to inform search engines of your regular updates. flareAI automates the update submissions to all the major search engines. flareAI helps growing your Shopify store on Google Search, and 20+ of the world’s largest free sales channels.

If you found the answer helpful consider supporting the Shopify Community by giving it a Like + Accept the solution.

Gina
flareAI

@ZenoPageBuilder @flareAI I have tried both of this code but have not been able to get it to work. Once added this appeared at top of the screen.

@Jay here is the code on the main search liquid. I have already selected within the theme editor to only show products.

{% comment %}theme-check-disable MissingTemplate{% endcomment %}
{% paginate search.results by 10 %}
{%- liquid
assign section_color = ‘primary’

assign enable_filtering = section.settings.enable_filtering
assign enable_sorting = section.settings.enable_sorting

if search.filters != empty
if enable_filtering == true
assign show_filters = true
endif
endif

assign main_class = ‘lg:col-span-12’

if show_filters
assign sidebar_class = ‘lg:col-span-2’
assign main_class = ‘lg:col-start-4 lg:col-span-9’
endif

assign sort_by = search.sort_by | default: search.default_sort_by
assign terms = search.terms | escape
assign search_url = ‘?q=’ | append: terms | append: ‘&options%5Bprefix%5D=last&sort_by=’ | append: sort_by
-%}

{% if enable_filtering == false and enable_sorting == true %} {% endif %}

{% if search.performed %} {{ 'general.search.title_with_results' | t }}: {{ 'general.search.title_with_results' | t }} {% else %} {{ 'general.search.title' | t }} {% endif %}

{{ 'general.search.placeholder' | t }} {% render 'icon-search' %} {{ 'general.search.submit' | t }}

{%- if search.results_count > 0 -%}

{{ 'general.search.results_with_count' | t: terms: search.terms, count: search.results_count }}

{%- endif -%}

{%- if show_filters or enable_sorting -%}

{%- if search.results_count > 0 -%}

{{ 'general.search.results_with_count' | t: terms: search.terms, count: search.results_count }}

{%- endif -%} {% if show_filters %}
{% render 'icon-filters' %} {{ 'facets.filters.title_tags' | t }}
{% endif %} {% if enable_sorting and search.performed and search.results_count > 0 %}
{{ 'facets.sorting.title' | t }}
{% endif %}
{%- endif -%}

{% if show_filters or enable_sorting %}

{% endif %}

{% if search.performed %}
{%- liquid
assign products = search.results | where: “object_type”, “product”
assign articles = search.results | where: “object_type”, “article”
assign pages = search.results | where: “object_type”, “page”
-%}
{% if search.results_count == 0 %}

{{ 'general.search.no_results' | t: terms: search.terms }} {% if search.filters != empty and section.settings.enable_filtering %} {{ 'facets.filters.use_fewer_filters_html' | t: link: search_url, class: 'underline' }}. {% endif %}

{% else %}
{%- if pages.size > 0 or articles.size > 0 -%}
{%- assign articles = search.results | where: "object_type", "article" %} {%- if articles.size > 0 -%}

{{ 'general.search.articles' | t }}

{%- endif -%} {%- if pages.size > 0 -%}

{{ 'general.search.pages' | t }}

{%- endif -%}
{%- endif -%}
{% endif %}

{% if paginate.pages > 1 %}
{% render ‘pagination’, paginate: paginate %}
{% endif %}

{% endif %}

{% if show_filters or enable_sorting %}

{{ 'facets.filters.title_tags' | t }}

{% render 'icon-close' %} {{ 'layout.drawers.close_menu' | t }}
{% render 'filters-mobile', results: search, section_color: section_color, enable_color_swatch_filters: section.settings.enable_color_swatch_filters, expand_filters: section.settings.expand_filters, capitalize_filters: section.settings.capitalize_filters, show_filter_count: section.settings.show_filter_count %}
{% endif %}
{% endpaginate %} {% schema %} { "name": "Search", "settings": [ { "type": "header", "content": "Filtering and Sorting" }, { "type": "checkbox", "id": "enable_filtering", "label": "Enable filtering", "info": "[Customize filters](/admin/menus)" }, { "type": "checkbox", "id": "expand_filters", "label": "Expand filters by default", "default": true }, { "type": "checkbox", "id": "show_filter_count", "label": "Show filter counts", "default": true }, { "type": "checkbox", "id": "enable_color_swatch_filters", "label": "Enable color swatch filters", "info": "[Learn how to set up swatches]([https://support.switchthemes.co/article/232-color-swatches](https://support.switchthemes.co/article/232-color-swatches))" }, { "type": "checkbox", "id": "enable_sorting", "label": "Enable sorting" } ] } {% endschema %}

Replace the following


With the following:


This is a hack though. Its not the most ideal

The other option is to do a real fix.

Replace the entire code with the below:

{% comment %}theme-check-disable MissingTemplate{% endcomment %}
{% paginate search.results by 10 %}
{%- liquid
assign section_color = 'primary'

assign enable_filtering = section.settings.enable_filtering
assign enable_sorting = section.settings.enable_sorting

if search.filters != empty
if enable_filtering == true
assign show_filters = true
endif
endif

assign main_class = 'lg:col-span-12'

if show_filters
assign sidebar_class = 'lg:col-span-2'
assign main_class = 'lg:col-start-4 lg:col-span-9'
endif

assign sort_by = search.sort_by | default: search.default_sort_by
assign terms = search.terms | escape
assign search_url = '?q=' | append: terms | append: '&options%5Bprefix%5D=last&sort_by=' | append: sort_by
-%}

{% endpaginate %}
{% schema %}
{
"name": "Search",
"settings": [
{
"type": "header",
"content": "Filtering and Sorting"
},
{
"type": "checkbox",
"id": "enable_filtering",
"label": "Enable filtering",
"info": "[Customize filters](/admin/menus)"
},
{
"type": "checkbox",
"id": "expand_filters",
"label": "Expand filters by default",
"default": true
},
{
"type": "checkbox",
"id": "show_filter_count",
"label": "Show filter counts",
"default": true
},
{
"type": "checkbox",
"id": "enable_color_swatch_filters",
"label": "Enable color swatch filters",
"info": "[Learn how to set up swatches](https://support.switchthemes.co/article/232-color-swatches)"
},
{
"type": "checkbox",
"id": "enable_sorting",
"label": "Enable sorting"
}
]
}
{% endschema %}

@Jay Thanks so much

1 Like

Same problem. My theme is Dawn. Here is code of main-search.liquid

{{ 'template-collection.css' | asset_url | stylesheet_tag }}
{{ 'component-card.css' | asset_url | stylesheet_tag }}
{{ 'component-price.css' | asset_url | stylesheet_tag }}
{{ 'component-search.css' | asset_url | stylesheet_tag }}

{%- if section.settings.enable_filtering or section.settings.enable_sorting -%}
  {{ 'component-facets.css' | asset_url | stylesheet_tag }}
  
{%- endif -%}

{% if section.settings.image_shape == 'blob' %}
  {{ 'mask-blobs.css' | asset_url | stylesheet_tag }}
{%- endif -%}

{%- liquid
  assign sort_by = search.sort_by | default: search.default_sort_by
  assign terms = search.terms | escape
  assign search_url = '?q=' | append: terms | append: '&options%5Bprefix%5D=last&sort_by=' | append: sort_by
-%}

{%- style -%}
  .section-{{ section.id }}-padding {
    padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
    padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
  }

  @media screen and (min-width: 750px) {
    .section-{{ section.id }}-padding {
      padding-top: {{ section.settings.padding_top }}px;
      padding-bottom: {{ section.settings.padding_bottom }}px;
    }
  }
{%- endstyle -%}

{% paginate search.results by 24 %}
  
    

      # 
        {%- if search.performed -%}
          {{- 'templates.search.title' | t -}}
        {%- else -%}
          {{- 'general.search.search' | t -}}
        {%- endif -%}
      
      
        {%- if settings.predictive_search_enabled -%}
          
        {%- endif -%}

      

      {%- if search.performed -%}
        {%- unless section.settings.enable_filtering or section.settings.enable_sorting -%}
          {%- if search.results_count > 0 -%}
            

{{ 'templates.search.results_with_count_and_term' | t: terms: search.terms, count: search.results_count }}

          {%- endif -%}
        {%- endunless -%}
        {%- if search.results_count == 0 and search.filters == empty -%}
          

{{ 'templates.search.no_results' | t: terms: search.terms }}

        {%- endif -%}
      {%- endif -%}
    

    {%- if search.performed -%}
      {%- if section.settings.enable_sorting and section.settings.filter_type == 'vertical' and search.filters != empty -%}
        
      {%- endif -%}
      

    {%- endif -%}
  
{% endpaginate %}
{% if section.settings.image_shape == 'arch' %}
  {% render 'mask-arch' %}
{%- endif -%}

{% schema %}
{
  "name": "t:sections.main-search.name",
  "tag": "section",
  "class": "section",
  "settings": [
    {
      "type": "range",
      "id": "columns_desktop",
      "min": 1,
      "max": 5,
      "step": 1,
      "default": 4,
      "label": "t:sections.main-search.settings.columns_desktop.label"
    },
    {
      "type": "header",
      "content": "t:sections.main-search.settings.header__1.content"
    },
    {
      "type": "select",
      "id": "image_ratio",
      "options": [
        {
          "value": "adapt",
          "label": "t:sections.main-search.settings.image_ratio.options__1.label"
        },
        {
          "value": "portrait",
          "label": "t:sections.main-search.settings.image_ratio.options__2.label"
        },
        {
          "value": "square",
          "label": "t:sections.main-search.settings.image_ratio.options__3.label"
        }
      ],
      "default": "adapt",
      "label": "t:sections.main-search.settings.image_ratio.label"
    },
    {
      "type": "select",
      "id": "image_shape",
      "options": [
        {
          "value": "default",
          "label": "t:sections.all.image_shape.options__1.label"
        },
        {
          "value": "arch",
          "label": "t:sections.all.image_shape.options__2.label"
        },
        {
          "value": "blob",
          "label": "t:sections.all.image_shape.options__3.label"
        },
        {
          "value": "chevronleft",
          "label": "t:sections.all.image_shape.options__4.label"
        },
        {
          "value": "chevronright",
          "label": "t:sections.all.image_shape.options__5.label"
        },
        {
          "value": "diamond",
          "label": "t:sections.all.image_shape.options__6.label"
        },
        {
          "value": "parallelogram",
          "label": "t:sections.all.image_shape.options__7.label"
        },
        {
          "value": "round",
          "label": "t:sections.all.image_shape.options__8.label"
        }
      ],
      "default": "default",
      "label": "t:sections.all.image_shape.label",
      "info": "t:sections.all.image_shape.info"
    },
    {
      "type": "checkbox",
      "id": "show_secondary_image",
      "default": false,
      "label": "t:sections.main-search.settings.show_secondary_image.label"
    },
    {
      "type": "checkbox",
      "id": "show_vendor",
      "default": false,
      "label": "t:sections.main-search.settings.show_vendor.label"
    },
    {
      "type": "checkbox",
      "id": "show_rating",
      "default": false,
      "label": "t:sections.main-search.settings.show_rating.label",
      "info": "t:sections.main-search.settings.show_rating.info"
    },
    {
      "type": "header",
      "content": "t:sections.main-collection-product-grid.settings.header__1.content"
    },
    {
      "type": "checkbox",
      "id": "enable_filtering",
      "default": true,
      "label": "t:sections.main-collection-product-grid.settings.enable_filtering.label",
      "info": "t:sections.main-collection-product-grid.settings.enable_filtering.info"
    },
    {
      "type": "select",
      "id": "filter_type",
      "options": [
        {
          "value": "horizontal",
          "label": "t:sections.main-collection-product-grid.settings.filter_type.options__1.label"
        },
        {
          "value": "vertical",
          "label": "t:sections.main-collection-product-grid.settings.filter_type.options__2.label"
        },
        {
          "value": "drawer",
          "label": "t:sections.main-collection-product-grid.settings.filter_type.options__3.label"
        }
      ],
      "default": "horizontal",
      "label": "t:sections.main-collection-product-grid.settings.filter_type.label",
      "info": "t:sections.main-collection-product-grid.settings.filter_type.info"
    },
    {
      "type": "checkbox",
      "id": "enable_sorting",
      "default": true,
      "label": "t:sections.main-collection-product-grid.settings.enable_sorting.label"
    },
    {
      "type": "header",
      "content": "t:sections.main-search.settings.header__2.content",
      "info": "t:sections.main-search.settings.header__2.info"
    },
    {
      "type": "checkbox",
      "id": "article_show_date",
      "default": true,
      "label": "t:sections.main-search.settings.article_show_date.label"
    },
    {
      "type": "checkbox",
      "id": "article_show_author",
      "default": false,
      "label": "t:sections.main-search.settings.article_show_author.label"
    },
    {
      "type": "header",
      "content": "t:sections.main-search.settings.header_mobile.content"
    },
    {
      "type": "select",
      "id": "columns_mobile",
      "default": "2",
      "label": "t:sections.main-search.settings.columns_mobile.label",
      "options": [
        {
          "value": "1",
          "label": "t:sections.main-search.settings.columns_mobile.options__1.label"
        },
        {
          "value": "2",
          "label": "t:sections.main-search.settings.columns_mobile.options__2.label"
        }
      ]
    },
    {
      "type": "header",
      "content": "t:sections.all.padding.section_padding_heading"
    },
    {
      "type": "range",
      "id": "padding_top",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_top",
      "default": 36
    },
    {
      "type": "range",
      "id": "padding_bottom",
      "min": 0,
      "max": 100,
      "step": 4,
      "unit": "px",
      "label": "t:sections.all.padding.padding_bottom",
      "default": 36
    }
  ]
}
{% endschema %}