On 9/17/2023 at 3:15 PM, elisolution said:I changed it in this way because It works better 👇:
{if $page.canonical}
<link rel="canonical" href="{$page.canonical}">
{elseif $page.canonical = 'index'}
<link rel="canonical" href="https://vidos-domofony.pl">
{/if}
With this, now I have 14 pages with Canonicalised errors.
Do you have any idea how to fix it? Most of this pages are sites, from help category: https://vidos-domofony.pl/category/9-pomoc
With homepage your solutions works great
On 8/28/2023 at 3:19 PM, LarsM said:I had the same issue in PrestaShop 8.1.1 and made this solution:
In the file: /themes/XXXX/templates/_partials/head.tpl
I changed this (lines 42-44):
{if $page.canonical} <link rel="canonical" href="{$page.canonical}"> {/if}To this:
{if $page.canonical} <link rel="canonical" href="{$page.canonical}"> {elseif $page.page_name == 'index'} <link rel="canonical" href="https://{$smarty.server.HTTP_HOST}/"> {/if}In additon to elisolution's answer above, this also checks whether we are actually on the home page (not just whether the canonical was set or not).
I tested this solution a bit and as far as I can see, it works as expected. Otherwise, please let me know!
Thanks
PS: Remember to change "https" to "http" if your site isn't handling requests through the HTTPS protocol. You could fiddle with variables like $smarty.server.REQUEST_SCHEME or $smarty.server.HTTPS to check automatically, but it seemed like overkill to me, as I always use the HTTPS protocol on my websites these days.
But with this, I have only 7 Canonicals missing