How to change the page title and description when .header.php included

I have searched in many forum sites how to change the title of every page.
Am new to Seo and having a php site to take care.

in Header file my title is xyz
where are the pages has the same tile.
How to change this. Can someone help.

i tried with <title><?php echo $page-title; ?></title>
after this home page show 0 in the title
still going further i tried to implement in index and about page with the code
$page-Title="Home";

and in About page
$page-Title="About-Us";

All the pages shows 0.

I would expect this to work, given that $page-title has been defined.
But here you have $page-Title="About-Us"; with a capital T on the word Tile. Where you echo you use a lower case t.
Variable names are case sensitive.

Thanks for your quick reply.

I would expect this to work, given that $page-title has been defined.
But here you have $page-Title=“About-Us”; with a capital T on the word Tile. Where you echo you use a lower case t.
Variable names are case sensitive.

I tried with it, But it display error while typing in file. or still can go further.

<?php echo $page-title; ?> This do i have to type in every page or only in 1 page. Is there i have to give any name for this file in header.php

Variables in PHP cannot have dashes and special characters in the name. They also cannot start with a number as well, but they can have numbers.

1 Like

Thanks all for your replies,
With your support i did it… It was really a good day for me.

I have 1 more question to ask.
How to make keywords and description unique for different page.

It depends on how your pages are created. For example you may have a database containing the descriptions for the pages or items included in the pages.
Or if it’s a few pages set up manually it can be done just like you did the title:-
$description = "Some text describing this page on my web site." ;

If you mean keywords for the “keywords” meta-tag, don’t waste your time, crawlers don’t even look at that any more, have not done for many years.

2 Likes

oh thanks, it was a great help in sharing.

crawlers - dont look for both is it ( Keywords & Description )

i have entered the value at $pagedescription, is it correct .

Crawlers don’t look at the “keywords” metatag so you may leave it out.
But the “description” is still important for SEO because it is often what people see in SERPs, so it needs to tell people it’s the page they are looking for, so they click it.

You may call the variable anything you like, within the bounds of naming rules as mentioned in post #4.
$pagedescription seems like a good descriptive name for the variable.

Thanks Sam… Am working on it.

Really have to thank you alot in helping in this situation.

Can i ask bit deeper. How to hide .php extension.

I have already applied a rule in .htaccess.

Now the url can display with our without php extension. But am looking for some code that i can hide the extension so users cannot see it.

Discussion continued here