pen paper writing icon WordPress icon png newspaper icon

[Kalles, Gecko, Elessi 3.0] – Change product URL structure on product grid

Some customers want to use a clear URL for product grid, example instead

http://www.website.com/collections/category/products/item1

to
http://www.website.com/products/item1

They want

http://www.website.com/products/item1 

We can see the collection will be disappear on the all product links and maybe it will better for SEO but you will be face with some issue related to theme features like Related can not work because we are detect a collection name from product link and get some products in the same collection.

The breadcrumb also not showing on product page because we can not get a collection name and next, back product without collection name in the URL.

So, if you can accept disable these features then please follow some step below to change a link url

1. Go to Theme Edit Code

Go to Edit code from Theme Customize

2. Open source code file

From Theme source code tree, open pr_loop_grid_1.liquid and pr_loop_grid_2.liquid

3. Change source code

Find and replace code below

Find:

{%- capture pr_url %}{{get_locale}}{{url_cat}}/products/{{pr_hdl}}{% endcapture -%}

Replace:

{%- capture pr_url %}{{get_locale}}}/products/{{pr_hdl}}{% endcapture -%}

And

Find:

{{product.url | within: collection}}

Replace:

{{product.url}}

Now, all done

Share:

Leave a Comment