Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi,
I can't find the best way for my problem.
I have this code in my theme :
{% if pageUrl contains '?page=' %}
{% assign special_canonical = true %}
{% assign canonicalPageArray = pageUrl | split: "=" %}
{% assign canonicalPageNumber = canonicalPageArray | last %}
{% endif %}
{%- endfor -%}
{% if special_canonical %}
<link rel="canonical" href="{{ canonical_url }}?page={{ canonicalPageNumber }}" />
{% elsif template contains 'collection' and current_tags %}
<meta name="robots" content="noindex" />
<link rel="canonical" href="{{ shop.url }}{{ collection.url }}" />
{% else %}
<link rel="canonical" href="{{ canonical_url }}" />
{% endif %}
I tried to use "asset_url" as shopify's IDE ask so I changed for :
{% if special_canonical %}
<link rel="canonical" href="{{ canonical_url | asset_url }}?page={{ canonicalPageNumber }}" />
{% elsif template contains 'collection' and current_tags %}
<meta name="robots" content="noindex" />
<link rel="canonical" href="{{ shop.url | asset_url }}{{ collection.url }}" />
{% else %}
<link rel="canonical" href="{{ canonical_url | asset_url }}" />
{% endif %}
My webscore increased by 15% but I avec full 404 errors on sitechecker...
Thoses errors concerns url not used with CDN like but it seems indexed by Google:
linked to url not used like :
Why asset_url seems wrong ?
What is preferable ?
Can someone explain to me what is going on ?
Thanks a lot
The asset_url filter is for generating a link to an asset (so an image for example). You should expect a CDN link to be returned. It doesn't make sense to use it like that.
What is the reason you had for doing that?
Thank you Jason !
I did that because of error messages in shopify template like :
I try to find what are problem with canonical url. Sitechecker always find issues
I am wondering this myself. The editor throws that code for me too. I wondered if part of the code was deleted accidentally or something but now I see it is like that with yours too.
Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025