Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi,
I have searched a lot for a solution to add a noindex by editing theme.liquid file to add "noindex" to paginated pages of collections, but don't think there is a solution and if there is then those pages are archieved.
Example: https://www.example.com/collections/example-category?page=4
I'm specifically looking to noindex all collection that contains '?page=" but unable to.
This is what I'm currently at, but not working
{% if template contains 'collection' and collection.handle contains '?page=' %}
<meta name="robots" content="noindex, follow" />
{% endif %}
If I try the below, it adds noindex to all the collections as well, which I do not want.
{% if template contains 'collection' and current_tags %}
<meta name="robots" content="noindex, follow" />
{% endif %}
or
{% if template contains 'collection' and current.filters != blank %}
<meta name="robots" content="noindex, follow" />
{% endif %}
Please only reply if you can provide a solution to the above. Thanking heaps in advance.
P.S: I'm not looking for a canonical solution, that thing is already working. Thanksssss
Hi @anksnz007
I have been trying to do the same but could not achieve the result and then I used the following code which got me the result I wanted. Please try it.
{% if canonical_url contains '?page=' %}
<meta name="robots" content="noindex" />
{% endif %}
Let me know if this works. It worked for me.
Best Regards,
Harsha
Web Developer
Thanks, it worked for me too....
I have also added it to my site after visiting this thread, Helpful info . Thanks
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024