Product Grid URL Adding Extra Subfolders

I have a product grid on my homepage that is generating incorrect URLs.

The correct destination URL is supposed to be something like this:
-“https://website.com/products/product-name-example/” but when I click on them I’m going to “https://website.com/collections/product-name-example/products/product-name-example/”.

From the front end of the site, these links seem to work sometimes and not work other times. I’m not really sure why…even so, for SEO reasons, I’d rather not link to an incorrect URL. I’d like to link to the correct canonicalized version of the webpage. Any idea on how I can fix this?

Hi, in order to fix this issue you need to find something similar in your theme code:

{% assign product_url = product.url | within: collection %}

and just remove the within filter so that it will look like this:

{% assign product_url = product.url %}

If you are not comfortable with code editing, the give me access to your store so that I can solve this problem for you by editing the code myself.

Thanks,

Abdul Moeed