Reputation: 460
I have a multilingual website, in order to optimize SEO, I want to add "hreflang" meta tags in the header.
The languages are organized in sub-folders like :
and so on... So I want to retrieve the languages sub-folder information into the tag :
**<link rel="alternate" hreflang="$insert_language_of_current_page" href="www.example.com/en">**
But i'm not very familiar with the TPL format of Prestashop. Is there already a parameter to do that ?
Thanks for help.
Upvotes: 0
Views: 1112
Reputation: 391
You can use this module, it adds the href langs rel to your shop automatically: https://addons.prestashop.com/en/seo-natural-search-engine-optimization/40888-seo-smo-assistant.html
If you want to do it yourself, for PrestaShop 1.7 find this file:
themes/[Your Theme]/templates/_partials/head.tpl
add this code to the end of the file:
{foreach from=$urls.alternative_langs item=pageUrl key=code}
<link rel="alternate" href="{$pageUrl}" hreflang="{$code}">
{/foreach}
For PS1.6 you need to find this file:
themes/[Your Theme]/header.tpl
Inside this file put the code bellow before the </head>
tag:
{if isset($language_code) && $language_code}
{foreach from=$languages key=k item=language name="languages"}
{if $language.iso_code == $lang_iso}
<!-- Current lang -->
<link rel="alternate" hreflang="{$language_code|escape:'html':'UTF-8'}" href="{if isset($force_ssl) && $force_ssl}{$base_dir_ssl|escape:'html':'UTF-8'}{else}{$base_dir|escape:'html':'UTF-8'}{/if}">
{/if}
{/foreach}
<!-- Other langs (if exist) -->
{foreach from=$languages key=k item=language name="languages"}
{if $language.iso_code != $lang_iso}
<link rel="alternate" hreflang="{$language.iso_code|escape:'html':'UTF-8'}" href="{if isset($force_ssl) && $force_ssl}{$base_dir_ssl|escape:'html':'UTF-8'}{else}{$base_dir|escape:'html':'UTF-8'}{/if}{$language.iso_code|escape:'html':'UTF-8'}/">
{/if}
{/foreach}
{/if}
Upvotes: 1