If your web site is designed using PHP that displays a static/same page title from an include file for all the pages of the site, it looks like a good idea, but in a longer run you may loose on SEO ratings since all your pages would have the same page title.
Here is a better and easy way of using a single "include" file for the header while still creating unique page titles for every page. This also works for meta tags. Please check the example below.
Here you would need a header file say "header.php" that would be included at the top of every page on your site - this generates the info contained in <head>.
The page we want to create a unique title tag for will be called "product.php":
Add the below code to "header.php". An "else" statement would display a default Meta tags if you have not specified the values/variable on the website pages:
<title><?php if(isset($title)) { print $title; } else { print "Default title comes here"; } ?></title>
<meta name="keywords" content="<?php if(isset($keywords)) { print $keywords; } else { print "keyword1,keyword2,keyword3,etc"; } ?>" />
<meta name="description" content="<?php if(isset($description)) { print $description; } else { print "Default description tag goes here."; } ?>" />
Add this code to product.php to specify the info you want used in the tags:
<?php
$title = "Add title to product.php here";
$keywords = "keyword1, keyword2, keyword3, etc";
$description = "Specify description of product.php here.";
require_once("header.php");
?>
Thats it! and you are good to go! :-)
No comments:
Post a Comment