All things Shopify and commerce
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
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,
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.
Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025