How can I change the product URL structure on my e-commerce site?

Hello everyone!!

I need again your help :slightly_smiling_face:

If the user goes from the collection page to the product page I have this URL structure: https:myshop.com/collections/collections_name/products/products_name

I need to change this URL to this: https:myshop.com/products/products_name

How can I do it?? Can you help me, please??

Thank you so much

Hi

This is Victor from PageFly - Shopify Page Builder App

It will require to modify the collection code in your liquid file

Step 1: Online Stores > Themes > More Actions > Edit code

Step 2: Seach for collection => Select each file and do the search in file for

{{ product.url | within: collection }}

If you see it, replace the whole line above with

{{ product.url }}

It depends on your theme you are using, but please go search around these files

Hope this can help you solve the issue

Best regards,

Victor | PageFly

Hi @PageFly-Victor ,

thank you so much for your reply.

I checking on template–product.liquid and template–product.liquid but I cannot found this {{ product.url | within: collection }}

Can you said me on which section I need to do this change?

Thank you so much again!

I found that:

{% capture current %}{% cycle 1, 2, 3, 4, 5, 6 %}{% endcapture %} {{ 'product-' | append: current | placeholder_svg_tag: 'icon--placeholder' }}
{{ 'general.onboarding.product_title' | t }} {{ 1999 | money }}

But if I remove “| within : collection” the URL doen’t change…

Hi @Niccolo8

Can you send me your page URL ( password if protected ) first?

Hi @PageFly-Victor ,

please check this page; https://lookeronline.com/collections/oakley-sunglasses/products/oakley-oo9013-24-306

I’d like the URL become the same of canonical.

It’s possible to do it?

Thank you so much!

@PageFly-Victor If you can, I can share the code to allow you like a collaborator.

@Niccolo8
Yes thank you, please send me the collab code for access.
That would be great

Hey @PageFly-Victor , what about in PageFly template files? Unfortunately, PageFly template files are autogenerated and removing “within: collection” tag from them will be overridden when a page published again.