Jump to content

Edit History

LarsM

LarsM

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.

LarsM

LarsM

I had the same issue in PrestaShop 8.1.1 and made this solution:

In the file: /public_html/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.

LarsM

LarsM

I had the same issue in PrestaShop 8.1.1 and made this solution:

In the file: /public_html/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 for my use, as I always use the HTTPS protocol on my websites these days.

LarsM

LarsM

I had the same issue in PrestaShop 8.1.1 and made this solution:

In the file: /public_html/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 :)

×
×
  • Create New...