How to Upload Meta Title, Description, Keywords, Open Graph tags and Canonical tags in WHMCS?

As you very well know that WHMCS do not have the option to add title for a specific product group, knowledgebase and announcements.

So here we are sharing the procedure by which you can add meta titles, descriptions, keywords and canonical tags easily: 

Step 1: Go to whmcsdir/templates/yourtemplate/header.tpl

Step 2: Download the header.tpl file

Step 3: Take a backup of the file

Step 4: Edit the file

Step 5: Find: <title>{if $kbarticle.title}{$kbarticle.title} – {/if}{$pagetitle} – {$companyname}</title>

Step 6: Replace this with the following code:

<!-- For product group id cart page -->

{if $smarty.get.gid eq '1'}

<title>Test Meta Title</title>
<meta name="description" content="Test Meta Description">
<meta name="keywords" content="Test, Meta, Keywords">
<link rel="canonical" href="yoururl.com"/>
<meta property="og:title" content="How to Become an SEO Expert (8 Steps)" /> 
<meta property="og:description" content="Get from SEO newbie to SEO pro in 8 simple steps." /> 
<meta property="og:image" content="https://ahrefs.com/blog/wp-content/uploads/2019/12/fb-how-to-become-an-seo-expert.png" />
{else if $smarty.get.gid eq '2'}

<title>Test Meta Title</title>
<meta name="description" content="Test Meta Description">
<meta name="keywords" content="Test, Meta, Keywords">
<link rel="canonical" href="yoururl.com"/>
<meta property="og:title" content="How to Become an SEO Expert (8 Steps)" />
<meta property="og:description" content="Get from SEO newbie to SEO pro in 8 simple steps." />
<meta property="og:image" content="https://ahrefs.com/blog/wp-content/uploads/2019/12/fb-how-to-become-an-seo-expert.png" />

<!-- Similarly you can add meta tags for other product groups -->


<!-- For product id cart pages-->

{else if $smarty.get.pid eq '2'}

<title> Product Title </title>
<meta name="description" content="product id 2">
<meta name="keywords" content="Test, Meta, Keywords">
<link rel="canonical" href="yoururl.com"/>
<meta property="og:title" content="How to Become an SEO Expert (8 Steps)" />
<meta property="og:description" content="Get from SEO newbie to SEO pro in 8 simple steps." />
<meta property="og:image" content="https://ahrefs.com/blog/wp-content/uploads/2019/12/fb-how-to-become-an-seo-expert.png" />

<!-- Similarly you can add meta tags for other products -->

<!-- For Main Announcement page -->

{else if $templatefile eq 'announcements'}

<title>Test Title</title>
<meta name="description" content="Test Meta Description">
<meta name="keywords" content="Test, Meta, Keywords">
<link rel="canonical" href="yoururl.com"/>
<meta property="og:title" content="How to Become an SEO Expert (8 Steps)" />
<meta property="og:description" content="Get from SEO newbie to SEO pro in 8 simple steps." />
<meta property="og:image" content="https://ahrefs.com/blog/wp-content/uploads/2019/12/fb-how-to-become-an-seo-expert.png" />

<!-- For a particular announcement -->
{else if $templatefile eq 'viewannouncement'}

<title>{$title}</title>
<meta name="description" content="Test Meta Description">
<meta name="keywords" content="Test, Meta, Keywords">
<link rel="canonical" href="yoururl.com"/>
<meta property="og:title" content="How to Become an SEO Expert (8 Steps)" />
<meta property="og:description" content="Get from SEO newbie to SEO pro in 8 simple steps." />
<meta property="og:image" content="https://ahrefs.com/blog/wp-content/uploads/2019/12/fb-how-to-become-an-seo-expert.png" />

<!-- For Main Knowledgebase -->

{else if $templatefile eq 'knowledgebase'}
<title>{$title}</title>
<meta name="description" content="Test Meta Description">
<meta name="keywords" content="Test, Meta, Keywords">
<link rel="canonical" href="yoururl.com"/>

{else}
<title>{if $kbarticle.title}{$kbarticle.title} - {/if}{$pagetitle} - {$companyname}</title>
{/if}

 

Note: The comments mentioned in the above code is just for describing the code breakdown. You can remove that or keep it as it is in the code.

So this is how you can add meta tags and canonical tags to the WHMCS website.