Liquid, JavaScript, themes, sales channels
Hello.
I am new to shopify. I need to noindex variant pages of products, but I can't find anything after looking it up. I have products that have no variants but still have variant URLs which I need to somehow noindex and remove canonical tags from
An example page is this
Original Page - https://www.bareoutdoors.com.au/products/sorrento-6-seat-round-dining-setting
Variant Page - https://www.bareoutdoors.com.au/products/sorrento-6-seat-round-dining-setting?variant=40141629325365
It's literally the same product but it's both showing up in google causing duplicate content.
Dear Support.
We have the same issue. Not only with variants.
The Googlebot and other bots crawls and index ugly pages (yes, we have canonical). But it should noindex.
It's a waste of crawl budget, ugly URLs and duplicate content.
Normally, I would stop crawling with robots.txt for parameters.
Disallow: *?
But if indexed and crawled, it's only for the future. We can't remove it: It's blocked now (to prevent further requests).
I have seen here some hints, which I have tried with the theme.liquid.
Like:
{% if handle contains 'seq=uniform' %}
<meta name="robots" content="noindex">
{% endif %}
from here:
But it seems, is has no influence inside the source code. It's index, follow furthermore.
Any idea? Many other people have the same issue.
I would add not nofollow. The crawler will break the crawling of other pages from here, and you have a lesser chance to remove the other bad URLs. Nofollow stop further crawling at this point.
Noindex is fine.
Due noindex, it’s also a crawling budget invest for the future. It's reduced the attempts in the future
https://www.seroundtable.com/google-noindex-404-codes-crawl-budget-34510.html
Best
7
Hello,
I've fixed the issue above for my website using JavaScript
Use this code below:
<script>
document.addEventListener('DOMContentLoaded', function() {
if (window.location.href.indexOf('?') > -1) {
var metaNoIndex = document.createElement('meta');
metaNoIndex.name = 'robots';
metaNoIndex.content = 'noindex';
document.getElementsByTagName('head')[0].appendChild(metaNoIndex);
}
});
</script>
hope this helps!
Hi Destman,
Where did you place this script? I've got the same issue, thousands of urls creatred from /search parameter, index, follow, so blocking is not an option until they are no index. Do you think it will work for me?
You must add the code in theme.liquid inside head tag.
Add the following codes at the end of your theme.liquid file. And then monitor your search console indexing results.
{%- if canonical_url="*?variant=*" -%}
<meta name="robots" content="noindex, nofollow">
{%- endif -%}
What's more, you can add Disallow: /*?variant=* on Robots testing tool, and test whether it can be indexed or not. Being blocked is the result you want.
User | RANK |
---|---|
37 | |
29 | |
13 | |
12 | |
9 |
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023