Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Not sure if this is the best way to do this but you could do it with a simple replace like this:
Replace
{{ content_for_header }}
inside your theme.liquid with (this is an example with hreflang tags from a different store):
{% comment %}{{ content_for_header }}{% endcomment %}
{{ content_for_header | replace: '<link rel="alternate" hreflang="en-DE" href="https://vibrantriver.myshopify.com/">
<link rel="alternate" hreflang="de-DE" href="https://vibrantriver.myshopify.com/de">
<link rel="alternate" hreflang="fr-DE" href="https://vibrantriver.myshopify.com/fr">', ''}}
Before:
After:
Hello Michaelivanov, I have a bilingual website in Turkish and English. How can I edit this code so that it is Turkish in Turkey and English in all other locations? Electirma.com TR Electrima.com/en All Location
Hi @faruk4,
If you're using Langify then you can enable the Language Detection feature (it detects the visitors' browser language which is usually a better choice) in
Langify -> Dashboard -> Switcher Configurator -> Detection & redirection
Once done every visitor with their browser language set to Turkish will see your store in Turkish.
Any visitors with other languages e.g. French as their browser language would will see your store in the fallback language which is English by default.
hi @hasansumon
Have you already found a solution? I had the same problem. Maybe it will help other community members.
The solution works for me, I have tested several stores.
{% capture content_for_header_custom %}
{{ content_for_header }}
{% endcapture %}
{% assign content_for_header_filtered = '' %}
{% assign lines = content_for_header_custom | split: '\n' %}
{% for line in lines %}
{% unless line contains 'hreflang=' %}
{% assign content_for_header_filtered = content_for_header_filtered | append: line | append: '\n' %}
{% endunless %}
{% endfor %}
{{ content_for_header_filtered }}
Only the lines with "hreflang" are removed here.
Then you can set your own "hreflangs" afterwards.
Best regards
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024