How to remove shopify product url variant at the end of the url?

Topic summary

A Shopify store owner wants to remove the ?variant=1234567 parameter from product page URLs, as their products don’t have multiple variants and the URLs appear cluttered. They’re using the Palo Alto theme.

Proposed Solutions:

  • Modify global.js: One user suggests editing the updateURL() function in the global.js file by removing the line that appends the variant parameter to the URL, leaving only the conditional check.

  • Edit theme.liquid: Another approach involves adding a JavaScript code snippet directly after the <head> tag in theme.liquid (with a video tutorial provided).

Additional Context:

  • The issue may also be caused by the Bold Subscriptions app’s bsub.js file, which forces variant parameters in URLs. Bold’s support team indicated this is expected behavior and cannot be modified at this time.

The discussion remains open with multiple potential solutions offered but no confirmed resolution from the original poster.

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

hi
i want to remove the variant=1234567 from my url pages. my product pages do not have multi variants and my url looks bad. working on palo alto theme

https://acpcovers.com/products/bimini-top-replacement-6-ft-42-inch-68-72-inch?variant=44240919593243

i was think i could edit this code? this is what i was looking at:

Yo not sure does it work on your theme but I had the same issue and this is how I got around it. Go to edit code find folder: global.js in that folder search for:

updateURL() { if (!this.currentVariant || this.dataset.updateUrl === ‘false’) return; window.history.replaceState({}, ‘’, ${this.dataset.url}?variant=${this.currentVariant.id}); }

Replace with:

updateURL() {

if (!this.currentVariant || this.dataset.updateUrl === ‘false’) return;

}

I’m not sure if this is your issue as well, but you’ll see this issue if you use the Bold Subscriptions app, thanks to their bsub.js file, _updateHistoryState. I reached out to their support team and they said,

“This is the expected behaviour of the app
No changes can be made to the bsub.js file at this time. I can submit a request to the developers so that they can be aware of this.”

If you want to remove variant from the url.

Here is a quick fix using a simple code snippet.

  1. Go to store dashboard → edit code → theme.liquid

  2. Find <head tag in theme.liquid file and just in the next line paste below javascript code.