Jump to content

head.tpl - hreflang="x-default"


Recommended Posts

Hello guys,

I have Prestashop 1.7.4.2 with Classic theme.

The site has two languages, so I need to place in the head:  <link rel="alternate" hreflang="x-default" href="https://www.example.com/en/collection/dresses" />

I have found that the head is managed through the head.tpl file, and the hreflang tags are called with:

{block name='head_hreflang'}
      {foreach from=$urls.alternative_langs item=pageUrl key=code}
            <link rel="alternate" href="{$pageUrl}" hreflang="{$code}">
      {/foreach}
  {/block}

My guess is that I will need to call the En version of the current page and use the same template to put the default tag.

How can I call the English version of the current page instead of looping through all available languages with $urls.alternative_langs

*Not a dev, just can read and cope with some code, so will appreciate any advice.

 

Thanks in advance.

Link to comment
Share on other sites

  • 1 year later...

Knowing that my default language is en, I handled it in the following way in head.tpl:

{block name='head_hreflang'}
   <link rel="alternate" href="{$urls.alternative_langs['en']}" hreflang="x-default">
   {foreach from=$urls.alternative_langs item=pageUrl key=code}
      <link rel="alternate" href="{$pageUrl}" hreflang="{$code}">
   {/foreach}
{/block}

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...