It works for me:
/layout/theme.liquid
{% assign content_for_header = content_for_header | replace: 'hreflang="fr-FR"', 'hreflang="fr"' %}
{{ content_for_header }}
Issue: Shopify automatically generates hreflang tags with incorrect country codes (e.g., en-SE, de-SE instead of en, de-DE), causing SEO problems for multilingual stores.
Primary Solution: Users can modify the auto-generated tags by editing the theme.liquid file using Liquid code to replace incorrect values:
{% assign content_for_header = content_for_header | replace: 'hreflang="en-SE"', 'hreflang="en"' %} before outputting {{ content_for_header }}Alternative Approach: Contact Shopify support to disable automatic hreflang generation, then manually add custom tags in the <head> section with conditional logic for different page templates (index, collection, product, etc.).
Key Considerations:
{% if template == "index" %} works for homepage, but other templates require {% if template.name == 'collection' %}Unresolved: Creating hreflang-specific sitemaps remains challenging with no automated solution available. One user reported duplicate tags appearing when implementing corrections.
It works for me:
/layout/theme.liquid
{% assign content_for_header = content_for_header | replace: 'hreflang="fr-FR"', 'hreflang="fr"' %}
{{ content_for_header }}