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

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

Niccolò8
Shopify Partner
33 0 2

Hello everyone!!

I need again your help 🙂

 

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

Niccolò
Replies 8 (8)

PageFly-Victor
Shopify Partner
7865 1786 3131

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

Niccolò8
Shopify Partner
33 0 2

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!

Niccolò
Niccolò8
Shopify Partner
33 0 2

I found that:

<article class="indiv-product">
<a href="{{ product.url | within: collection }}" title="{% if product %}{{product.title}}{% else %}{{ 'general.onboarding.product_title' | t }}{% endif %}">
{% capture current %}{% cycle 1, 2, 3, 4, 5, 6 %}{% endcapture %}
{{ 'product-' | append: current | placeholder_svg_tag: 'icon--placeholder' }}
</a>
<div class="hp-title">
<a href="{{ product.url | within: collection }}">
<span class="indiv-product-title-text">{{ 'general.onboarding.product_title' | t }}</span>
<span class="money money-styling">
{{ 1999 | money }}
</span>
</a>
</div>
</article>

 

But if I remove "| within : collection" the URL doen't change...

Niccolò
PageFly-Victor
Shopify Partner
7865 1786 3131

Hi @Niccolò8 

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

Niccolò8
Shopify Partner
33 0 2

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!

Niccolò
Niccolò8
Shopify Partner
33 0 2

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

Niccolò
PageFly-Victor
Shopify Partner
7865 1786 3131

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

ntofigzade
Visitor
1 0 0

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.