SEO information after the title tag in PrestaShop

Gajendra Singh
Published: December 16, 2022

In this blog, we are going to learn how to show SEO or any other information in the head tag after the title tag.

Let’s see together how to do that with PrestaShop.

Sometimes, we need to show SEO or any other information in the head tag like meta and link tags for SEO.

Thanks to the available hooks, it’s super easy by using the PrestaShop default hook displayAfterTitleTag

We will register the ‘displayAfterTitleTag‘ hook in our module using the below code.

Searching for an experienced
Prestashop Company ?
Read More


$this->registerHook(
    array(
        'displayAfterTitleTag',
    )
);

After registering, We will do the below code in our module main file.

public function hookDisplayAfterTitleTag(array $params)
{
    /** Here you can assign any seo or other info that you want to show in head tag after the title tag */
    return $this-     >fetch('module:your_module_name/views/templates/hook/seoinfo.tpl');
}

Now, we will create seoinfo.tpl file at path your_module_name/views/templates/hook/ to show information in head tag.

<link rel="canonical" href="custom_canonical">
<link rel="alternate" hreflang="iso_code" href="custom_href">
<meta name="author" content="John Doe">
<meta name="robots" content="noindex" />

Now, you will see in your web page head tag.

seo_info_after_title_tag_in_prestashop

That’s all about this blog. Hope it will help you.

If you are facing any issues or doubts in the above process, please feel free to contact us in the comment section.

We 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].

Source: webkul.com