Removing product variant URL ?v=

Highlighted
New Member
2 0 0

@Jason wrote:

What makes you think this url is used in SEO activites?

Do remember that JavaScript is modifying the history state after the page loads. It's not actually loading that url. If you slow down the page load you'll see the change happen.

I doubt that removing this will make any impact on your SEO efforts


One product can be found by different URLs on the website.

For example,
https://charmingjewellerystore.co.uk/collections/best-sellers/products/family-nest-birthstone-neckla...

https://charmingjewellerystore.co.uk/collections/jewellery-for-her/products/family-nest-birthstone-n...

both URLs lead to the same product page and this is an issue for SEO.

The product page should have a unique URL as follows: https://charmingjewellerystore.co.uk/products/family-nest-birthstone-necklace. The same formula should be used for all products. 

0 Likes
Highlighted
Tourist
3 0 1

@DerbyshireSEO, while you're correct that search engines should resolve to one URL — you can instruct them to do this by using what's called a Canonical URL, which you add as a metatag — e.g.  

 

<link rel="canonical" href="https://ca.kotn.com/products/mens-essential-crew">

Removing the ?variant= part of the URL is a bad idea, it will break the back button making it harder for users to add products to cart, and making product variants un-shareable. As long as you have canonical URLs specified, you will be covered from an SEO perspective.

Consider collections — your store probably has multiple collections, right? You might be able to get to one by going to yourstore.com/collections/collection-name/product-name … you wouldn't want to delete the collections from the URL, would you? It provides a lot of value to the user – again, this is resolved by the canonical URL!

 

You can read more on canonical URLS & duplicates here: https://support.google.com/webmasters/answer/139066?hl=en

0 Likes
Highlighted
New Member
1 0 0

@DerbyshireSEO This can be easily fixed within the theme by locating the code {{ product.url | within: collection }} and changing it to {{ product.url }}  this way your products will only appear to come from one product page.

0 Likes
Highlighted
New Member
1 0 0

1. Im Download Themes Files ->

2. And with app search "?variant=" in all documents - and find in ThemeName.js file this part:

var newUrl = [window.location.protocol, '//', window.location.host, window.location.pathname, '?variant=', variant.id];
      var variantUrl = newUrl.join('');
      window.history.replaceState({
        path: variantUrl
      }, '', variantUrl);

3. After this im delete , '?variant=', variant.id and save 

4. Done - all products - open without variant

0 Likes
Highlighted
New Member
1 0 0

Hi Jason,

 

Is it possible in the url description to have the

window.location.protocol + '//' + window.location.host + window.location.pathname 

+ (the variant name) instead of 

 

'?variant=' + variant.id;

 

I understand your point about sharing the url or bookmarking and would like that the variant name comes in the url as well.

 

Thank you.

0 Likes
Highlighted
Tourist
3 0 1

Hey @Trivin — sorry to say that's not possible. Shopify is very specific and strict in how it handles routing (the rules that create the URLs). There is probably some work you could have done to make it possible, but it would be quite a lot of work and likely cost you quite a bit — and then on top of that you'd be in a tricky spot if you ever needed to update your theme, and if something breaks, Shopify's team wouldn't be able to help you. 

I totally understand, from an OCD perspective, why you'd want the nice clean URLs — but I'd strongly suggest you just forget about it and move on — you're looking at way too many hurdles to jump over for such a small reward. Just my two cents!

0 Likes
Highlighted
New Member
1 0 0

This worked perfectly with the Canopy Theme.

 

thanks a lot!!

0 Likes