Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
I am getting issues with my hreflang tags on my Shopify store, specifically...
This is what I have tried inside theme.liquid:
<head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"> <meta name="theme-color" content="{{ settings.color_secondary }}"> {%- if canonical_url != blank -%} <link rel="canonical" href="{{ canonical_url }}"> <link rel="canonical" href="{{ canonical_url }}" hreflang="en-us"> <link rel="canonical" href="{{ canonical_url }}" hreflang="en-gb"> {%- endif -%}
Can anyone help me out and let me know what I am doing wrong?
Here is the issues popping up in SEMrush letting me know that I have hreflang conflicts and what and where they are.
I suppose you are using Shopify Payments. Unless you have an advanced use case, you should not have to worry about hreflang tag attributes, Shopify automatically adds them in the <head> tag for you based on the available languages and regions used by your store.
You can see on this screen capture there are 5 of them, including the default one:
So yours are duplicate, what's more they use a canonical rel attribute instead of the rel alternate attribute. From what I can see, I'd say you shoud most likely remove the code you added and leave it as it was initially, which I suppose are those 2 lines:
<link rel="canonical" href="{{ canonical_url }}" hreflang="en-us">
<link rel="canonical" href="{{ canonical_url }}" hreflang="en-gb">
Hey Max,
I took out the two lines. Although, Shopify automatically does this SEMrush and Google are both detecting hreflang errors how can I fix these issues as they directly effect my SEO.
I am having the same issue with SEMRush. Were you able to resolve this?