How do I correct misconfigured hreflang tags in my online store?

Topic summary

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:

  • Use {% assign content_for_header = content_for_header | replace: 'hreflang="en-SE"', 'hreflang="en"' %} before outputting {{ content_for_header }}
  • Multiple replacements can be chained for different languages

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:

  • Template detection syntax varies: {% if template == "index" %} works for homepage, but other templates require {% if template.name == 'collection' %}
  • The replacement method preserves translated URL slugs better than full rewrites
  • Sitemap.xml cannot be modified in Shopify; HTML implementation is the recommended solution

Unresolved: Creating hreflang-specific sitemaps remains challenging with no automated solution available. One user reported duplicate tags appearing when implementing corrections.

Summarized with AI on October 30. AI used: claude-sonnet-4-5-20250929.

Exactly!

This in, in-fact the approach I used in the end.
As the alternative “rewrite” the hreflang tags in full, was causing issues with the translated URL slugs.

Good solution for now! Thanks.

Still looking for a sitemap solution…but I am guessing that will need to be a custom solution.
I see nothing “out of the box” that offers this today.