How can I redirect links to specific language subdomains?

Hi,

Since I just added german language to our website, I wish to include the option “DE” in our top navigation menu with a link to our german subdomain: “de.mywebsite.com”. Since the original code was made, we changed into subdomains based on language and location and therefore, I am experiencing a bit of issue with the particular coding. I have now tried different solutions but via the coding the “DE”-link always redirects to “mywebsite.com - This website is for sale! - mywebsite Resources and Information.”.

Can anybody please help me with the correct code in order to let the redirects go to our subdomains “de.mywebsite.com”, “da.mywebsite.com” and “en.mywebsite.com” instead of “/de”, “/da” and “/en”?

I have attached the code down below:


            {% if request.locale.iso_code == 'en' %}
                {% assign locale_link = '/en' %}
            {% else request.locale.iso_code == 'de' %}
                {% assign locale_link = '/de' %}
            {% else %}
                {% assign locale_link = '' %}
            {% endif %}
            - DA
            

          - DE
            

            - EN
            
        

    {% endif %}

    {% if show_language %}
        {% if request.locale.iso_code == 'en' %}
            {% assign locale_link = '/' %}
        {% else %}
            {% assign locale_link = '' %}
        {% endif %}
        - DA
        

        - DE
        

        - EN
        

    {% endif %}
1 Like