Shopify automatically appends a variant ID to product URLs even if the product doesn´t have variants

Topic summary

A Shopify store owner using the Dawn theme is experiencing an issue where variant IDs are automatically appended to product URLs (e.g., ?variant=50023565328731), even for products without actual variants—only default variants.

Proposed Solution:
A respondent suggested commenting out specific code in the global.js file:

window.history.replaceState({ }, '', `${this.dataset.url}?variant=${this.currentVariant.id}`);

This would prevent variant IDs from appearing when variants are changed.

Current Status:

  • The original poster couldn’t locate the suggested code in their global.js file
  • The issue persists for products without variants, not just during variant selection
  • The respondent offered to provide direct assistance via email or store access, noting that JavaScript code is responsible for appending the variant parameter

Unresolved: The discussion remains open, with the solution not yet implemented or verified for products lacking variants.

Summarized with AI on October 27. AI used: claude-sonnet-4-5-20250929.

Shopify automatically appends a variant ID to product URLs when variants exist, even if the product only has a default variant.

Is there a way to delete this variant ID for these products that don´t have any variants? I want my URLs to be as clean as possible. My website is https://losplaceresdelola.com/

An example of this issue is this product: https://losplaceresdelola.com/products/succionador-clitoris-clio?variant=50023565328731

Where I would like to dele the ?variant=50023565328731

I´m using the Dawn theme

Thank you!

Hi @PlaceresDeLola ,

Go to Themes >> Edit code >> Global.js, search and comment the below code
window.history.replaceState({ }, ‘’, ${this.dataset.url}?variant=${this.currentVariant.id});

Now, whenever you change the varient, the id will not appear.

If you still need any help, feel free to message me or reply me.

1 Like

Thank you very much for the information. The issue that I have is that most of my products don´t have variants and Shopify is automaticaly adding the variant slug for these products. The soluction provided should resolve this?

I also didn´t quite understand your solution. I tried to search for the code you provided window.history.replaceState({ }, ‘’, ${this.dataset.url}?variant=${this.currentVariant.id}) on my Global.js and I couldn´t find anything similar.

Thank you!

@PlaceresDeLola Can you please message me or mail me at ankit@aitrillion.com ?
Basically, I will request you the store access and will add the details so it will be resolved. Basically, it is a JS code which is adding the varient at the end of the URL.