Re: Don't use /collections/name/ in products URL

Don't use /collections/name/ in products URL

wrapsify
Tourist
4 1 0

Hey everyone,

 

I could use some help with an issue I'm having. So, whenever I click on a product, the URL contains "/collections/name" like this:

URL: https://wrapsify.com/collections/motorcycle-gifts/products/classic-bike-keychain-to-my-man-ride-safe...

 

But what I actually want is just this: https://wrapsify.com/products/classic-bike-keychain-to-my-man-ride-safe-always-come-home-to-me-gkt26...

 

I find the extra "/collections/motorcycle-gifts" part unnecessary and would prefer a cleaner URL like "wrapsify.com/products/...".

 

 

Monosnap Monosnap 2024-04-14 12-09-01.png

Does anyone know how I can fix this?

 

Thanks in advance!

Replies 4 (4)

pawankumar
Shopify Partner
644 95 119

Hi @wrapsify 
For such URLs, there is a within: collection filter in your code, you have to remove it to get rid of it.
Thanks!

- Need a Shopify developer? Chat on WhatsApp +91-9467121281
- Coffee Tip: Buymeacoffee  | Email: thepkpawankumar@gmail.com
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Best regards,
Pawan
wrapsify
Tourist
4 1 0

I want to remove /collections/ when accessing /products/ pages, is there any tutorial article?

pawankumar
Shopify Partner
644 95 119

No, actually you will find it in a file product-item.liquid, product-card.liquid or similar file

It depends upon theme and you need some liquid knowledge to remove it so that you don't remove any other part

Thanks!

- Need a Shopify developer? Chat on WhatsApp +91-9467121281
- Coffee Tip: Buymeacoffee  | Email: thepkpawankumar@gmail.com
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
Best regards,
Pawan

tim
Shopify Partner
3911 395 1439

You have a Turbo theme.

I do not know if your theme is the same version as the one I have, but in mine it's necessary to modify the following files:

In Sections:

  product-recently-viewed-template.liquid

 

In Snippets:

 

  collection-swatch.liquid

  product-details.liquid

  product-slider.liquid

  product-thumbnail.liquid

  quick-shop-button.liquid

 

You need to search for "| within: collection" and remove these found strings.

 

For example, in snippets/collection-swatch.liquid there is code like:

 

<a href="{{ variant.url | within: collection }}" class="swatch" ...

 

 
This needs to be modified to be like:

 

<a href="{{ variant.url }}" class="swatch" ...

 

 

There may be multiple occurrences in some files.

And do not forget to make a theme duplicate before you proceed with any modifications!

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com