PrestaShop Developer Conference
PrestaShop Developer Conference
Paris, France - November 6, 2024
Let's talk code, commerce and open source.
Table of Contents

Notice: You are browsing the documentation for PrestaShop 9, which is currently in development.

You might want to read the documentation for the current version, PrestaShop 8. Read the current version of this page

Head

The head part is very important in terms of SEO and performance.

Have look at Classic’s head part to see real life examples.

Assets

PrestaShop 1.7 changed the way asset work, and it means the way they are added inside the <head> tag of your page changed a bit too.

There are 2 important files to use:

  • _partials/stylesheets.tpl
  • _partials/javascript.tpl

These 2 files are used to take full advantage of the features like async loading for javascript or automatic inline for CSS.

The _partials/javascript.tpl has to be included at the bottom of your page as well.
  {block name='stylesheets'}
    {include file="_partials/stylesheets.tpl" stylesheets=$stylesheets}
  {/block}

  {block name='javascript_head'}
    {include file="_partials/javascript.tpl" javascript=$javascript.head vars=$js_custom_vars}
  {/block}

Those 2 subtemplates are very simple, they loop and print each provided assets.

SEO

A lot of meta and SEO information belong here, there is a special block for it so template which extend this layout can easily redefine the page title or description.

  {block name='head_seo'}

    <title>{block name='head_seo_title'}{$page.meta.title}{/block}</title>
    <meta name="description" content="{block name='head_seo_description'}{$page.meta.description}{/block}">
    <meta name="keywords" content="{block name='head_seo_keywords'}{$page.meta.keywords}{/block}">

    {if $page.meta.robots !== 'index'}
      <meta name="robots" content="{$page.meta.robots}">
    {/if}

    {if $page.canonical}
      <link rel="canonical" href="{$page.canonical}">
    {/if}

  {/block}