Jump to content
Sign in to follow this  
vittyc

SEO - Meta Titles and Descriptions

Recommended Posts

Is there anyway I can control and update the meta titles and descriptions for pages. 

Currently the homepage says 'Portal Home' and if I go to WordPress hosting for example, I get 'Shopping Cart'

Can anyone recommended a plugin or a tutorial on how to get around this please? 

Cheers

Share this post


Link to post
Share on other sites
13 minutes ago, vittyc said:

Can anyone recommended a plugin or a tutorial on how to get around this please?

if you wanted to edit the header template, you could follow the post below as a starting point...

Share this post


Link to post
Share on other sites
23 minutes ago, brian! said:

if you wanted to edit the header template, you could follow the post below as a starting point...

Thanks for the quick response Brian, makes sense - but how does that relate to "pages" where it's pulled from ID e.g. https://www.domain.com/cart.php?gid=1

Share this post


Link to post
Share on other sites
31 minutes ago, vittyc said:

Thanks for the quick response Brian, makes sense - but how does that relate to "pages" where it's pulled from ID e.g. https://www.domain.com/cart.php?gid=1

are you saying that you want each product group (and each cart step within that) to all have unique page titles and descriptions ?? possibly including the group name in the cart page titles ??

Share this post


Link to post
Share on other sites

Yeah if that's possible....?

I tried; 

{elseif $templatefile eq 'cart.php?gid=1'}

and no change, I don't think $templatefile is right, but not 100% sure what would work...

Share this post


Link to post
Share on other sites
On 06/01/2019 at 18:03, vittyc said:

Yeah if that's possible....?

oh it's possible in any number of ways, it just depends how thorough you need it to be, how complicated you want the code to look and what your desired output is.

On 06/01/2019 at 18:03, vittyc said:

I tried; 


{elseif $templatefile eq 'cart.php?gid=1'}

and no change, I don't think $templatefile is right, but not 100% sure what would work...

that wouldn't work (but you already know that now!) - templatefile is the correct variable to use, but it equals your template name (with at least one exception), not the query strings after the question mark.

let's say that you still want to go down the multilingual route using language strings to do this as outlined in the above thread, we can expand the code to the following...

	{if ($gid && !empty($LANG.pagetitle.{$templatefile}.{$gid}))}
		<title>{$LANG.pagetitle.{$templatefile}.{$gid}}</title>
	{elseif ($checkout)}
		<title>{$LANG.pagetitle.checkout}</title>
	{elseif ($productinfo && !empty($LANG.pagetitle.{$templatefile}.{$productinfo.pid}))}
		<title>{$LANG.pagetitle.{$templatefile}.{$productinfo.pid}}</title>	
	{elseif (!$inShoppingCart && !empty($LANG.pagetitle.{$templatefile}))}
		<title>{$LANG.pagetitle.{$templatefile}}</title>
	{else}
		<title>{if $kbarticle.title}{$kbarticle.title} - {/if}{$pagetitle} - {$companyname}</title>
	{/if}
	{if ($gid && !empty($LANG.metakeywords.{$templatefile}.{$gid}))}
		<meta name="keywords" content="{$LANG.metakeywords.{$templatefile}.{$gid}}">
	{elseif ($productinfo && !empty($LANG.metakeywords.{$templatefile}.{$productinfo.pid}))}
		<meta name="keywords" content="{$LANG.metakeywords.{$templatefile}.{$productinfo.pid}}">
	{elseif (!$gid && !empty($LANG.metakeywords.{$templatefile}))}
		<meta name="keywords" content="{$LANG.metakeywords.{$templatefile}}">
	{/if}
	{if ($gid && !empty($LANG.metadescription.{$templatefile}.{$gid}))}
		<meta name="description" content="{$LANG.metadescription.{$templatefile}.{$gid}}">
	{elseif ($productinfo && !empty($LANG.metadescription.{$templatefile}.{$productinfo.pid}))}
		<meta name="keywords" content="{$LANG.metadescription.{$templatefile}.{$productinfo.pid}}">		
	{elseif (!$gid && !empty($LANG.metadescription.{$templatefile}))}
		<meta name="description" content="{$LANG.metadescription.{$templatefile}}">
	{/if}

now i've kept the code as simple as practically possible to understand and expand (no I really have!), but let me explain those 5 title if statements...

  1. if $gid exists and a language override exists for that product group, then output that language string - this should only occur with the Products template page, e.g the group categories opening page.
  2. if you are at checkout, then use the "checkout"  language override - this rule is because for both viewcart and checkout, $templatefile = "viewcart", so this allows you to distinguish between viewcart and checkout.
  3. if $productinfo exists and a language override exists for that product (could still use product groups if required though), then output that language string - this should apply to the three cart configuration template pages.
  4. if you are not in any cart page, and a language override exists for that template, then output that language string - this should be all pages outside of the cart.
  5. if none of the above 4 rules match, then it defaults to using the standard format - e.g article titles in the knowledgebase, or pagetitle / company name

also, if you create an English language override, but not an equivalent Dutch string, then Dutch visitors will see the default titles.

I would have thought that meta tags would be irrelevant for the 3 cart configuration pages for SEO purposes, but you could expand the if statements used in the title block to the meta tags section if you feel that they should be added.

with regards to the language overrides themselves, they would be in the following format...

$_LANG['pagetitle']['homepage'] = 'The Home Page';
$_LANG['metakeywords']['homepage'] = 'Alpha, Beta, Delta';
$_LANG['metadescription']['homepage'] = 'This is the home page of WHMCS';
$_LANG['pagetitle']['products']['10'] = 'Shared Hosting';
$_LANG['metakeywords']['products']['10'] = 'Alpha, Beta, Delta SH';
$_LANG['metadescription']['products']['10'] = 'This is Shared Hosting';
$_LANG['pagetitle']['configureproductdomain']['45'] = 'Basic Hosting';
$_LANG['pagetitle']['viewcart'] = 'Cart Summary';
$_LANG['pagetitle']['checkout'] = 'Checkout';

so for product groups, the number in the final square brackets relates to the $gid value for that product group; for products, the number in the final square brackets is the $pid value for that product; it will make sense once you start adding them! 🙂

if you didn't want to use new language overrides in the titles, then you could do it with existing variables instead...

	{if ($gid)}
		<title>{$groupname}</title>
	{elseif ($checkout)}
		<title>{$LANG.checkout}</title>
	{elseif ($productinfo)}
		<title>{$productinfo.name}</title>	
	{elseif (!$inShoppingCart)}
		<title>{$templatefile|capitalize}</title>
	{else}
		<title>{if $kbarticle.title}{$kbarticle.title} - {/if}{$pagetitle} - {$companyname}</title>
	{/if}

obviously, I don't know what you're desired output is, but you could add {debug} to any specific template to get a list of available variables in that template and adjust your output accordingly.

I suppose if you wanted to stick exactly with the {$pagetitle} - {$companyname} format for all pages outside of the KB, you could use a ClientAreaPage hook to just set the $pagetitle variable based on $templatefile value or whatever... with a possible secondary clientareaheadoutput hook to add the meta tags for a page... though if you are deviating from the above title format in any way, you would really need to amend the titles in the template rather than via a hook.

test the above header template code thoroughly as obviously I haven't spent the time going through each and every template - so if you see any glaring issues that you can't fix with other variables, let me know. thanks.png

Share this post


Link to post
Share on other sites

Thanks

On 1/7/2019 at 6:14 PM, brian! said:

oh it's possible in any number of ways, it just depends how thorough you need it to be, how complicated you want the code to look and what your desired output is.

that wouldn't work (but you already know that now!) - templatefile is the correct variable to use, but it equals your template name (with at least one exception), not the query strings after the question mark.

let's say that you still want to go down the multilingual route using language strings to do this as outlined in the above thread, we can expand the code to the following...


	{if ($gid && !empty($LANG.pagetitle.{$templatefile}.{$gid}))}
		<title>{$LANG.pagetitle.{$templatefile}.{$gid}}</title>
	{elseif ($checkout)}
		<title>{$LANG.pagetitle.checkout}</title>
	{elseif ($productinfo && !empty($LANG.pagetitle.{$templatefile}.{$productinfo.pid}))}
		<title>{$LANG.pagetitle.{$templatefile}.{$productinfo.pid}}</title>	
	{elseif (!$inShoppingCart && !empty($LANG.pagetitle.{$templatefile}))}
		<title>{$LANG.pagetitle.{$templatefile}}</title>
	{else}
		<title>{if $kbarticle.title}{$kbarticle.title} - {/if}{$pagetitle} - {$companyname}</title>
	{/if}
	{if ($gid && !empty($LANG.metakeywords.{$templatefile}.{$gid}))}
		<meta name="keywords" content="{$LANG.metakeywords.{$templatefile}.{$gid}}">
	{elseif ($productinfo && !empty($LANG.metakeywords.{$templatefile}.{$productinfo.pid}))}
		<meta name="keywords" content="{$LANG.metakeywords.{$templatefile}.{$productinfo.pid}}">
	{elseif (!$gid && !empty($LANG.metakeywords.{$templatefile}))}
		<meta name="keywords" content="{$LANG.metakeywords.{$templatefile}}">
	{/if}
	{if ($gid && !empty($LANG.metadescription.{$templatefile}.{$gid}))}
		<meta name="description" content="{$LANG.metadescription.{$templatefile}.{$gid}}">
	{elseif ($productinfo && !empty($LANG.metadescription.{$templatefile}.{$productinfo.pid}))}
		<meta name="keywords" content="{$LANG.metadescription.{$templatefile}.{$productinfo.pid}}">		
	{elseif (!$gid && !empty($LANG.metadescription.{$templatefile}))}
		<meta name="description" content="{$LANG.metadescription.{$templatefile}}">
	{/if}

now i've kept the code as simple as practically possible to understand and expand (no I really have!), but let me explain those 5 title if statements...

  1. if $gid exists and a language override exists for that product group, then output that language string - this should only occur with the Products template page, e.g the group categories opening page.
  2. if you are at checkout, then use the "checkout"  language override - this rule is because for both viewcart and checkout, $templatefile = "viewcart", so this allows you to distinguish between viewcart and checkout.
  3. if $productinfo exists and a language override exists for that product (could still use product groups if required though), then output that language string - this should apply to the three cart configuration template pages.
  4. if you are not in any cart page, and a language override exists for that template, then output that language string - this should be all pages outside of the cart.
  5. if none of the above 4 rules match, then it defaults to using the standard format - e.g article titles in the knowledgebase, or pagetitle / company name

also, if you create an English language override, but not an equivalent Dutch string, then Dutch visitors will see the default titles.

I would have thought that meta tags would be irrelevant for the 3 cart configuration pages for SEO purposes, but you could expand the if statements used in the title block to the meta tags section if you feel that they should be added.

with regards to the language overrides themselves, they would be in the following format...


$_LANG['pagetitle']['homepage'] = 'The Home Page';
$_LANG['metakeywords']['homepage'] = 'Alpha, Beta, Delta';
$_LANG['metadescription']['homepage'] = 'This is the home page of WHMCS';
$_LANG['pagetitle']['products']['10'] = 'Shared Hosting';
$_LANG['metakeywords']['products']['10'] = 'Alpha, Beta, Delta SH';
$_LANG['metadescription']['products']['10'] = 'This is Shared Hosting';
$_LANG['pagetitle']['configureproductdomain']['45'] = 'Basic Hosting';
$_LANG['pagetitle']['viewcart'] = 'Cart Summary';
$_LANG['pagetitle']['checkout'] = 'Checkout';

so for product groups, the number in the final square brackets relates to the $gid value for that product group; for products, the number in the final square brackets is the $pid value for that product; it will make sense once you start adding them! 🙂

if you didn't want to use new language overrides in the titles, then you could do it with existing variables instead...


	{if ($gid)}
		<title>{$groupname}</title>
	{elseif ($checkout)}
		<title>{$LANG.checkout}</title>
	{elseif ($productinfo)}
		<title>{$productinfo.name}</title>	
	{elseif (!$inShoppingCart)}
		<title>{$templatefile|capitalize}</title>
	{else}
		<title>{if $kbarticle.title}{$kbarticle.title} - {/if}{$pagetitle} - {$companyname}</title>
	{/if}

obviously, I don't know what you're desired output is, but you could add {debug} to any specific template to get a list of available variables in that template and adjust your output accordingly.

I suppose if you wanted to stick exactly with the {$pagetitle} - {$companyname} format for all pages outside of the KB, you could use a ClientAreaPage hook to just set the $pagetitle variable based on $templatefile value or whatever... with a possible secondary clientareaheadoutput hook to add the meta tags for a page... though if you are deviating from the above title format in any way, you would really need to amend the titles in the template rather than via a hook.

test the above header template code thoroughly as obviously I haven't spent the time going through each and every template - so if you see any glaring issues that you can't fix with other variables, let me know. thanks.png

Thanks

Share this post


Link to post
Share on other sites

Hello, please how to have this work for those URL located in child menu under Store :
 

client/cart.php?a=add&domain=register
cart.php?a=add&domain=transfer

cart.php?a=view

 

 

Share this post


Link to post
Share on other sites
	{if ($gid)}
		<title>{$groupname}</title>
	{elseif ($checkout)}
		<title>{$LANG.checkout}</title>
	{elseif ($productinfo)}
		<title>{$productinfo.name}</title>	
	{elseif ($templatefile|strstr:'store/')}
		<title>{$breadcrumb.{($breadcrumb|count)-1}.label}</title>
	{elseif ($templatefile eq "domainregister")}
		<title>{$_LANG.registerdomainname}</title>		
	{elseif ($templatefile eq "domaintransfer")}
		<title>{$_LANG.transferdomainname}</title>		
	{elseif ($templatefile eq "viewcart")}
		<title>{$_LANG.registerdomainname}</title>		
	{elseif (!$inShoppingCart)}
		<title>{$templatefile|capitalize}</title>
	{else}
		<title>{if $kbarticle.title}{$kbarticle.title} - {/if}{$pagetitle} - {$companyname}</title>
	{/if}

 

Share this post


Link to post
Share on other sites
7 minutes ago, brian! said:

	{if ($gid)}
		<title>{$groupname}</title>
	{elseif ($checkout)}
		<title>{$LANG.checkout}</title>
	{elseif ($productinfo)}
		<title>{$productinfo.name}</title>	
	{elseif ($templatefile|strstr:'store/')}
		<title>{$breadcrumb.{($breadcrumb|count)-1}.label}</title>
	{elseif ($templatefile eq "domainregister")}
		<title>{$_LANG.registerdomainname}</title>		
	{elseif ($templatefile eq "domaintransfer")}
		<title>{$_LANG.transferdomainname}</title>		
	{elseif ($templatefile eq "viewcart")}
		<title>{$_LANG.registerdomainname}</title>		
	{elseif (!$inShoppingCart)}
		<title>{$templatefile|capitalize}</title>
	{else}
		<title>{if $kbarticle.title}{$kbarticle.title} - {/if}{$pagetitle} - {$companyname}</title>
	{/if}

 

Thank you very much Mr @brian! but please is there a way to use the first solution, I mean with using new language overrides in the titles 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated