Canonial Tags not correct. How can I change them?

Solved
New Member
7 0 0

Dear Shopify friends, 

 

my Google Search Console warns that I have duplicate content. As i found, my canonial tags are not set correct by Shopify. Here is the example: 

 

https://halal-online-shop.de/collections/halal-sussigkeiten

This is the collections page with the correct canonial tag: 

 <link rel="canonical" href="https://www.halal-online-shop.de/collections/halal-sussigkeiten">  

 

 

And now I take a duplicate page, where the same halal sweets are shown: 

https://www.halal-online-shop.de/collections/halal-sussigkeiten?page=1u0026variant%3D5528010096681

Here, the canonial tag should be the one i posted above. But the canonial tag is: 

<link rel="canonical" href="https://www.halal-online-shop.de/collections/halal-sussigkeiten?page=1u0026variant%3d5528010096681">

 

I have many duplicate pages, so I need to adjust the canonial tags to: <link rel="canonical" href="https://www.halal-online-shop.de/collections/halal-sussigkeiten">, so I can signal that my collection page is the correct page. 

 

Does anybody know how I can adjust the canonial tag? Or do you have any other solution? This issue is killing my ranking right now.

 

Best regards

 

Tayfun 

 

 

 

0 Likes
Shopify Partner
39 1 4

Hi Tayfun,

 

{{ canonical_url }}

should disregard the url-parameters and return "https://www.halal-online-shop.de/collections/halal-sussigkeiten"

 

Alternatively you can constuct the url with this:

 

{{ shop.url }}{{ collection.url }}

Hope this helps :)

0 Likes
New Member
7 0 0

Dear leinaD, 

 

thank you for your response. 

 

But unfortuntaley i dont know what to do with

{{ canonical_url }}

 

Can you please expand the information? Thank you. 

 

best regards

 

Tayfun 

 

0 Likes
Astronaut
1089 149 274

Go into your theme.liquid file in your Layout Folder in Online Store > Actions > Edit Code. You'll be looking for a tag like:

 

<link rel="canonical" href="{{ canonical_url }}" hreflang="en-us" />

You're looking for the rel="canonical" as there will be multiple link tags. Check what your href says, what @leinaD was saying is that you can use

{{ canonical_url }}

in the href attribute. Alternatively you can use an if statement to construct it like:

 

  {% if template contains 'collection' %}
  <link rel="canonical" href="{{ shop.url }}{{ collection.url }}" hreflang="en-us" />
  {% else %}
  <link rel="canonical" href="{{ canonical_url }}" hreflang="en-us" />
  {% endif %}

 

If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish :D
1 Like
New Member
7 0 0

Thank you. 

 

I checked my theme.liquid

 

There the i found: 

 

<link rel="canonical" href="{{ canonial_url }}">

 

I changed it now to 

 

<link rel="canonical" href="{{ "https://www.halal-online-shop.de/collections/halal-sussigkeiten"}}">

 

Do you think this works? 

0 Likes

Success.

Astronaut
1089 149 274

No, double curly quotes indicate Liquid output. {{ canonical_url }} is a Shopify object. It's returns a unique url for whatever page you're on:

 

https://www.shopify.com/partners/blog/canonical-urls

 

What you had previously should be good, but since you're having issues use an if statement like I said. Instead of what you have now, try:

 

 

  {% if template contains 'collection' %}
  <link rel="canonical" href="{{ shop.url }}{{ collection.url }}"/>
  {% else %}
  <link rel="canonical" href="{{ canonical_url }}"/>
  {% endif %}

 

 

What you have now will make your problem even worse, it's just going to show that same url on every page you have. This says that "if you're on a collection page, make the canonical url the shop url and the collection url. Otherwise, use the canonical_url object to output a url." I've never seen a page created with a ?page= 1u0026variant%3d5528010096681 - I don't know if that's some app you're using or what.

If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish :D
0 Likes
New Member
7 0 0

The Code you posted above works. You are a genius!

0 Likes
Astronaut
1089 149 274

Haha, not really, but I'm glad you got it working. Feel free to message me if you have any other questions.

If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish :D
0 Likes