The cannonical and hreflang tags are useful if our store is multi-language. It avoids duplication of url for each store and helps the site SEO by mentioning the url of different languages.
This will indicate to the google crawlers which is the alternative link for each languages and / or geographical areas where the online store and the canonical url of the product are available, category, manufacturer list, which in many cases will be very useful.
We can add the cannonical and hreflang tags on prestashop at the header.tpl template file. The template files are under theme/yourthemename folder.
The following code needs to be added inside the head section:
{ if $ page_name == 'category' }
<link rel = "canonical" href = "{$ link-> getCategoryLink ($ smarty.get.id_category, null, $ id_lang, null, null)}" />
{ if $ languages | @ count > 1 } { foreach $ languages as $ lang } <link rel = "alternate" hreflang = "{$ lang.iso_code}" href = "{$ link-> getCategoryLink ($ smarty.get. id_category, null, $ lang.id_lang, null, null)} "/> { / foreach } { / if }
{ if $ start ! = $ stop } { if $ p ! = 1 && $ p_previous ! = 1 } { assign var = 'p_previous' value = $ p - 1 }
<link rel = "prev" href = "{$ link-> getCategoryLink ($ smarty.get.id_category, null, $ id_lang, null, null)} { $ link - > goPage ( $ requestPage , $ p_previous ) } " / > { / if }
{ if $ pages_nb > 1 AND $ p ! = $ pages_nb } { assign var = 'p_next' value = $ p + 1 }
<link rel = "next" href = "{$ link-> getCategoryLink ($ smarty.get.id_category, null, $ id_lang, null, null)} { $ link - > goPage ( $ requestPage , $ p_next ) } " / > { / if } { / if }
{ / if }
{ if $ page_name == 'product' }
<link rel = "canonical" href = "{$ link-> getProductLink ($ smarty.get.id_product, null, null, null, $ id_lang, null, 0, false)}" />
{ if $ languages | @ count > 1 } { foreach $ languages as $ lang } <link rel = "alternate" hreflang = "{$ lang.iso_code}" href = "{$ link-> getProductLink ($ smarty.get. id_product, null, null, null, $ lang.id_lang, null, 0, false)} "/> { / foreach } { / if }
{ / if }
{ if $ page_name == 'cms' && $ smarty . get . id_cms > 0 }
<link rel = "canonical" href = "{$ link-> getCMSLink ($ smarty.get.id_cms, null, false, $ id_lang)}" />
{ if $ languages | @ count > 1 } { foreach $ languages as $ lang } <link rel = "alternate" hreflang = "{$ lang.iso_code}" href = "{$ link-> getCMSLink ($ smarty.get. id_cms, null, false, $ lang.id_lang)} "/> { / foreach } { / if }
{ / if }
{ if $ page_name == 'manufacturer' && $ smarty . get . id_manufacturer > 0 }
<link rel = "canonical" href = "{$ link-> getManufacturerLink ($ smarty.get.id_manufacturer, null, $ id_lang)}" />
{ if $ languages | @ count > 1 } { foreach $ languages as $ lang } <link rel = "alternate" hreflang = "{$ lang.iso_code}" href = "{$ link-> getManufacturerLink ($ smarty.get. id_manufacturer, null, $ lang.id_lang)} "/> { / foreach } { / if }
{ / if }
{ if $ page_name == 'manufacturer' && ! isset ( $ smarty . get . id_manufacturer ) }
<link rel = "canonical" href = "{$ link-> getPageLink ('manufacturer', 'true', $ id_lang)}" />
{ if $ languages | @ count > 1 } { foreach $ languages as $ lang } <link rel = "alternate" hreflang = "{$ lang.iso_code}" href = "{$ link-> getPageLink ('manufacturer', ' true ', $ lang.id_lang)} "/> { / foreach } { / if }
{ / if }
{ if $ page_name == 'index' }
<link rel = "canonical" href = "{$ link-> getPageLink ('index', 'true', $ id_lang)}" />
{ if $ languages | @ count > 1 } { foreach $ languages as $ lang } <link rel = "alternate" hreflang = "{$ lang.iso_code}" href = "{$ link-> getPageLink ('index', ' true ', $ lang.id_lang)} "/> { / foreach } { / if }
{ / if }
This will indicate to the google crawlers which is the alternative link for each languages and / or geographical areas where the online store and the canonical url of the product are available, category, manufacturer list, which in many cases will be very useful.
We can add the cannonical and hreflang tags on prestashop at the header.tpl template file. The template files are under theme/yourthemename folder.
The following code needs to be added inside the head section:
{ if $ page_name == 'category' }
<link rel = "canonical" href = "{$ link-> getCategoryLink ($ smarty.get.id_category, null, $ id_lang, null, null)}" />
{ if $ languages | @ count > 1 } { foreach $ languages as $ lang } <link rel = "alternate" hreflang = "{$ lang.iso_code}" href = "{$ link-> getCategoryLink ($ smarty.get. id_category, null, $ lang.id_lang, null, null)} "/> { / foreach } { / if }
{ if $ start ! = $ stop } { if $ p ! = 1 && $ p_previous ! = 1 } { assign var = 'p_previous' value = $ p - 1 }
<link rel = "prev" href = "{$ link-> getCategoryLink ($ smarty.get.id_category, null, $ id_lang, null, null)} { $ link - > goPage ( $ requestPage , $ p_previous ) } " / > { / if }
{ if $ pages_nb > 1 AND $ p ! = $ pages_nb } { assign var = 'p_next' value = $ p + 1 }
<link rel = "next" href = "{$ link-> getCategoryLink ($ smarty.get.id_category, null, $ id_lang, null, null)} { $ link - > goPage ( $ requestPage , $ p_next ) } " / > { / if } { / if }
{ / if }
{ if $ page_name == 'product' }
<link rel = "canonical" href = "{$ link-> getProductLink ($ smarty.get.id_product, null, null, null, $ id_lang, null, 0, false)}" />
{ if $ languages | @ count > 1 } { foreach $ languages as $ lang } <link rel = "alternate" hreflang = "{$ lang.iso_code}" href = "{$ link-> getProductLink ($ smarty.get. id_product, null, null, null, $ lang.id_lang, null, 0, false)} "/> { / foreach } { / if }
{ / if }
{ if $ page_name == 'cms' && $ smarty . get . id_cms > 0 }
<link rel = "canonical" href = "{$ link-> getCMSLink ($ smarty.get.id_cms, null, false, $ id_lang)}" />
{ if $ languages | @ count > 1 } { foreach $ languages as $ lang } <link rel = "alternate" hreflang = "{$ lang.iso_code}" href = "{$ link-> getCMSLink ($ smarty.get. id_cms, null, false, $ lang.id_lang)} "/> { / foreach } { / if }
{ / if }
{ if $ page_name == 'manufacturer' && $ smarty . get . id_manufacturer > 0 }
<link rel = "canonical" href = "{$ link-> getManufacturerLink ($ smarty.get.id_manufacturer, null, $ id_lang)}" />
{ if $ languages | @ count > 1 } { foreach $ languages as $ lang } <link rel = "alternate" hreflang = "{$ lang.iso_code}" href = "{$ link-> getManufacturerLink ($ smarty.get. id_manufacturer, null, $ lang.id_lang)} "/> { / foreach } { / if }
{ / if }
{ if $ page_name == 'manufacturer' && ! isset ( $ smarty . get . id_manufacturer ) }
<link rel = "canonical" href = "{$ link-> getPageLink ('manufacturer', 'true', $ id_lang)}" />
{ if $ languages | @ count > 1 } { foreach $ languages as $ lang } <link rel = "alternate" hreflang = "{$ lang.iso_code}" href = "{$ link-> getPageLink ('manufacturer', ' true ', $ lang.id_lang)} "/> { / foreach } { / if }
{ / if }
{ if $ page_name == 'index' }
<link rel = "canonical" href = "{$ link-> getPageLink ('index', 'true', $ id_lang)}" />
{ if $ languages | @ count > 1 } { foreach $ languages as $ lang } <link rel = "alternate" hreflang = "{$ lang.iso_code}" href = "{$ link-> getPageLink ('index', ' true ', $ lang.id_lang)} "/> { / foreach } { / if }
{ / if }
ReplyDeleteGood Blog with the required information and information are very effective ..!!
swift developer certification training in chennai
swift developer certifications training in Bangalore
Cyber security training in chennai
cyber security training in Bangalore
Software Testing Course in Chennai
Software Testing Institute in Bangalore
AI courses in chennai
Full stack developer training in chennai
Graphic Design institute in Chennai