Contents

Once you have created a custom page in WHMCS you may want to define SEO data for it. The SEO data includes a page title, meta description and meta tags although it is possible to add any meta data you like. In this tutorial you'll learn how to add this functionality to any pages you create.

Targeting Pages

In order to assign data to a page we must first find a way to target it. Within WHMCS there are two pre-defined variables that we can use to detect which page the user is on. They are:

$filename - This variable is the name of the PHP filename used by the page. e.g company.php = company

$templatefile - This variable is the name of the TPL filename used by the page. e.g company.tpl = company

Adding SEO Data To A Custom Page

Keeping note of the way we can target a page let's say for example you create a page named custom.php and want to assign SEO data to it.

Open the following file (contains the SEO functions):

/public_html/templates/your_template/includes/seo.tpl

You can use the following code to target this page using the $filename:

{elseif $filename eq "custom"}
	<title>Page title goes here</title>
	<meta name="description" content="Meta description goes here" />
	<meta name="keywords" content="Meta, tags, go, here" />

This code needs to be added to the seo.tpl file above the bottom {else} line. You can duplicate this code and use it for as many custom pages as you like. Keep in mind that you will need to replace the custom reference with the filename of the page you created without the .php extension. If for example you created a page name hostingservice.php you would need to use eq "hostingservice".

Save the file and re-load the page and you should now see the SEO functions applied when viewing the page source.

Comments

If you have any questions please leave a comment below or contact our support.