Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi everyone,
When working with different markets Shopify generates automatically hreflang tags which usually aren't correct. Recently, for a client that has 5 different languages automatically it generated more than 500 lines of hreflang, which doesn't make any sense. We asked Shopify to remove them in order to be able to add our own ones. We thought this would work, but unfortunately not fully. Here is an example of another client. What we added is:
{% if hrefhandle %}
{%- liquid
assign hrefhandle = hrefhandle | remove: "/en"
assign hrefhandle = hrefhandle | remove: "/en-ar"
assign hrefhandle = hrefhandle | remove: "/en-eu"
assign hrefhandle = hrefhandle | remove: "/en-int"
assign hrefhandle = hrefhandle | remove: "/es-int"
assign hrefhandle = hrefhandle | remove: "/es"
-%}
<link rel="alternate" hreflang="es-es" href="https://domain.com{{ hrefhandle }}" />
<link rel="alternate" hreflang="en" href="https://domain.com/en-int{{ hrefhandle }}" />
<link rel="alternate" hreflang="en-gb" href="https://domain.com/en-eu{{ hrefhandle }}" />
<link rel="alternate" hreflang="es" href="https://domain.com/es-int{{ hrefhandle }}" />
<link rel="alternate" hreflang="en-sa" href="https://domain.com/en-ar{{ hrefhandle }}" />
<link rel="alternate" hreflang="x-default" href="https://domain.com/en-int{{ hrefhandle }}" />
{% endif %}
The problem with this is that no matter the subfolder that I visit, Shopify then automatically adds the same handle for all versions, for both Spanish and English versions. Following the example, I got:
<link rel="alternate" hreflang="es-es" href="https://domain.com/collections/zapatillas-padel" />
<link rel="alternate" hreflang="en" href="https://domain.com/en-int/collections/zapatillas-padel" />
<link rel="alternate" hreflang="en-gb" href="https://domain.com/en-eu/collections/zapatillas-padel" />
<link rel="alternate" hreflang="es" href="https://domain.com/es-int/collections/zapatillas-padel" />
<link rel="alternate" hreflang="en-sa" href="https://domain.com/en-ar/collections/zapatillas-padel" />
<link rel="alternate" hreflang="x-default" href="https://domain.com/en-int/collections/zapatillas-padel" />
when it should be:
<link rel="alternate" hreflang="es-es" href="https://domain.com/collections/zapatillas-padel" />
<link rel="alternate" hreflang="en" href="https://domain.com/en-int/collections/padel-shoes" />
<link rel="alternate" hreflang="en-gb" href="https://domain.com/en-eu/collections/padel-shoes" />
<link rel="alternate" hreflang="es" href="https://domain.com/es-int/collections/zapatillas-padel" />
<link rel="alternate" hreflang="en-sa" href="https://domain.com/en-ar/collections/padel-shoes" />
<link rel="alternate" hreflang="x-default" href="https://domain.com/en-int/collections/padel-shoes" />
Is there any way to solve this properly?
Shopify 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, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025