Remove variant id from product url?

Tourist
3 0 14

I was trying to update my site for Shopify variant images (annoying this doesn't work natively!), and although I believe I changed everything back to it's original state, now I am getting variant ids at the end of every product url, and "copy of" before each product name.  For example:

http://vconlinestore.ca/products/copy-of-temple-of-doom-dark?variant=1023654464

Instead of:

http://vconlinestore.ca/products/temple-of-doom-dark

Any insight on how to fix this would be much appreciated, thanks!

0 Likes
Shopify Partner
1 0 1

"Copy of" isn't happening on every product, that seems like its something you might have created in the admin area by mistake.

For the variants somewhere in your templates (maybe product? might be code for selecting the first available variant?) you have

$('.single-option-selector:eq(0)').val("Men's").trigger('change');
$('.single-option-selector:eq(1)').val("Small").trigger('change');

being generated.

because the Shopify.OptionSelectors have enableHistoryState set to true when the change event is triggered by the above code its adding the variant _GET var to the url.  

You'll need to work out where those triggers are being made and why to decide if you can just delete them or not.

 

 

1 Like
Tourist
3 0 14

Thanks so much Craig!  I found the Shopify.OptionSelectors function in theme.liquid, changed "true" to "false", and the offending string is gone.  Cheers!

 

 // initialize multi selector for product
    $(function() {
      new Shopify.OptionSelectors("product-select", { product: {{ product | json }}, onVariantSelected: selectCallback, enableHistoryState: false });

 

1 Like
Excursionist
54 0 14

Does anyone have any advice on how this affects search rankings with Google? Do they see these Variants as duplicate content? for example we write 300+ word descriptions. But the only difference the variant changes is the size or color. 

Would ths be considered duplicate content by Google?

Example here:

http://www.bikiniluxe.com/collections/swimwear/products/equinoccio-del-mar?variant=2974048321

Visit our Luxury Bikini and Women's Fashion Website, Featuring many highly sought after and limited edition pieces from around the world! http://www.bikiniluxe.com
0 Likes
New Member
1 0 0

Hi, 

To remove ?variant=30927664709766 Go to the product template or product.liquid file and search: 

enableHistoryState: true

replace it to  enableHistoryState: false

that's it. 

Contact me at shahzadali906@gmail.com if more help needed! 

Thank you!

0 Likes