How can I prevent Google from indexing specific tag-filtered pages on my website?

Topic summary

Users are struggling to prevent Google from indexing Shopify collection pages that include filter parameters (e.g., URLs with size and category tags like /collections/all/size__xxl%20category__outerwear). These filtered pages appear in search results with unwanted meta titles.

Attempted Solutions (unsuccessful):

  • Adding noindex meta tags in theme.liquid using conditions like {% if template contains "collection" and collection.handle == "?filter" %}
  • Blocking filtered URLs in robots.txt with patterns like Disallow: /collections/*?*filter*
  • Using metafield-based noindex rules

Core Technical Issue:
The main challenge is that filter parameters appear after a question mark (?) in the URL, which isn’t part of Shopify’s URL handle. This makes it impossible to target these pages using standard Liquid template conditions that check collection.handle or similar variables.

One user shared a more complex code snippet that handles various URL patterns and uses metafields, but the fundamental problem of targeting the ? character in filtered URLs remains unresolved. The discussion is ongoing with no confirmed working solution.

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

Try this set in your theme header - you can modify to fit your needs.

  • note I also set metafield to collection or page so it is a quick solution for you too.
{% if handle contains 'types' or template contains 'search' or template contains 'cart' %}
{% elsif product_url contains 'view=list' %}
{% elsif request.page_type == 'collection' or request.page_type == 'page' %}
{% if template contains 'collection' and current_tags %}
{% elsif template contains 'collection' and product_url contains 'page=' %}
{% elsif collection.metafields.robots.noindex == 'false' or page.metafields.robots.noindex == 'false' %}
{% else %}
{% endif %}
{% elsif product_url contains 'variant=' or product_url contains 'currency=' %} 
{% else %}
{% endif %}