PrestaShop is a popular open-source e-commerce platform. Sometimes, you need to add custom tags to the <head>
section of your theme to improve SEO, connect third-party services, or add additional styles and scripts. In this article, we'll show you how to do this using the Classic theme in PrestaShop as an example.
Step 1: Understanding the Classic Theme Structure
Before making any changes, it's important to understand the structure of a PrestaShop theme. The Classic theme, like other themes, has its own templates and style files located in the /themes/classic/
directory. The header.tpl
file, which includes the <head>
section, references a separate head.tpl
file.
Step 2: Locating and Editing the head.tpl File
-
Open the directory for the Classic theme:
/themes/classic/templates/_partials/
-
Find the
head.tpl
file. This file contains the HTML code that forms the content of your store's<head>
section. -
Make a backup of the
head.tpl
file in case you need to revert to the original state.
Step 3: Making Changes to head.tpl
Now that you have access to the head.tpl
file, you can add the necessary tags. For example, if you want to add a <meta>
tag for Google Search Console verification, here's how to do it:
-
Open
head.tpl
in any text editor. -
Find the section where
<meta>
tags are already present, and add your new tag. For example:<meta name="google-site-verification" content="your_verification_code">
- Save the changes to the
head.tpl
file.
Step 4: Clearing the Cache
After making changes to the template file, you need to clear the PrestaShop cache for the changes to take effect. This can be done through the admin panel:
- Go to "Advanced Parameters" -> "Performance".
- Click the "Clear Cache" button.
Conclusion
Adding custom tags to the <head>
section in PrestaShop is quite simple if you understand the theme structure and know which files to edit. By following the steps outlined above, you can add any necessary tags to the Classic theme. Always remember to make backups before making any changes to avoid data loss and to be able to revert to the previous version in case of an error.
Thus, the process of adding a tag to the <head>
section of the Classic theme in PrestaShop involves editing the head.tpl
file, which is included in the header.tpl
file, making template management more convenient and structured.