Back to Top

Create custom layouts in the PrestaShop theme

Updated 15 May 2024

In this blog, we will learn how to add custom layouts to an existing PrestaShop theme. PrestaShop already has some predefined layouts, such as full width, two columns, three columns, and so on. However, if you need to add a new layout, you can create custom layouts.

To add a custom layout, we need to create a file under the templates/layouts folder of the theme and modify the config/theme.yml file. Modifying files in existing themes is not a recommended approach because when you update the theme, changes will be lost. Therefore, we will create a child theme. PrestaShop supports child theme functionality, which means you can extend the parent theme’s behavior.

To create a child theme in PrestaShop, we create a folder under the themes folder and name it according to your wish in small letters (for example, “mytheme”). Create another folder under “mytheme” and name it “config.” Under the “config” folder, create a new file called “theme.yml” and put the following content in this file:

parent: classic
name: mytheme
display_name: My theme for layout
version: 1.0.0
  use_parent_assets: true

    from: 8.1.0
    to: ~

      name: Custom layout
      description: This is custom layout
      name: Full Width
      description: No side columns, ideal for distraction-free pages such as product pages.
      name: Three Columns
      description: One large central column and 2 side columns.
      name: Two Columns, small left column
      description: Two columns with a small left column
      name: Two Columns, small right column
      description: Two columns with a small right column

Here, we have extended the default PrestaShop “classic” theme. You can also visit the below link to understand the theme.yml file parameters in detail:

Searching for an experienced
Prestashop Company ?
Find out More

In the available_layouts params, we have defined our custom layout name and description:

      name: Custom layout
      description: This is custom layout

Now, we have to create this layout file under the templates/layouts folder so create this folder and create a file called custom-layout.tpl inside the templates/layouts folder and put the below content:

{extends file='layouts/layout-both-columns.tpl'}

{block name='content_wrapper'}
  <div id="content-wrapper" class="js-content-wrapper col-xs-12 col-md-8 col-lg-9">
    {hook h="displayContentWrapperTop"}
    {block name='content'}
      <p>Hello world! This is HTML5 Boilerplate.</p>
    {hook h="displayContentWrapperBottom"}

Note: The layout file name must be the same as defined in the theme.yml file. In the custom-layout.tpl file, we have extended the parent theme (classic) layout-both-columns.tpl layout.

You can see the newly added child theme in the theme list (Design > Theme & Logo > Theme), activate the child theme and click on “Choose layouts”:

Choose theme layouts

After clicking on “Choose layouts”, a new window opens and you will see the custom layout option in the dropdown:

Custom theme layout

That’s all about this blog.

If any issue or doubt please feel free to mention it in the comment section.

I would be happy to help.

Also, you can explore our PrestaShop Development Services & a large range of quality PrestaShop Modules.

For any doubt contact us at [email protected].

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.

Back to Top

Message Sent!

If you have more details or questions, you can reply to the received confirmation email.

Back to Home