NOINDEX Dynamic Pages Using Filter on Custom Object Properties

I have a product listing page that leverages dynamic pages with custom objects. The query runs a filter to only select products with an in_stock value of TRUE.

My issue is that the products that are not in stock are still getting indexed and are returned in my site search results and appear with “NULL” page titles.

Is there a way to dynamically block the products for pages that are not in stock from being indexed?

I know that I could explicitly block the pages from being indexed in the robots.txt config, but I’d like to make this dynamic since the in stock values will change over time.

Hi @hubrob,

Thanks for reaching out to the Community!

I’d like to invite some of our experts to join the conversation and get their input on this question.

Hi @Jnix284, @himanshurauthan, @franksteiner79 :slightly_smiling_face:

Feel free to jump in with any suggestions or ideas you might have—everyone’s take on this would be really helpful!

Thanks!

Diana

Hi @hubrob,

You could try adding some conditional logic in your page template to show the noindex meta tag when in_stock value is false.

For example:

{% if in_stock == false %}

 {% require_head %}
 <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />
 {% end_require_head %}

{% endif %}

The require_head tag will make sure that it is added to the <head> of your page, so you can essentially place that wherever you are checking the stock.

Hope this helps!