Remove Products from Google Search Index

Topic summary

A user is attempting to prevent low-stock products (1 unit or less) from appearing in Google search results by adding meta robots noindex tags to their Shopify theme.liquid file.

Current Issue:

  • Code has been inserted in the <head> section but products still appear in search results
  • The implementation uses Liquid templating to conditionally add noindex tags based on inventory quantity

Status:

  • The user hasn’t been able to test whether the code works for any product quantities yet
  • Seeking alternative code variations or suggestions to resolve the indexing problem
  • Looking for more generic testing approaches to validate the solution

The discussion remains open with no responses or solutions provided yet.

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

Hi,

I’m trying to add some code that will prevent products of 1 or less stock show up in google searches. I’ve inserted this code in the of theme.liquid but it the product still shows up.

Does anyone have any variations of this code I could try or even something more generic to test this out on, as I have not been able to test if it works for any quantity of product yet.

Thanks,

Calum

 {% if product.variants.first.inventory_quantity <= 1 %}
  <meta name="robots" content="noindex">
{% endif %}