Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I use meta tags in a php website?

Status
Not open for further replies.

Usalabs1

Technical User
Jun 29, 2003
131
US
After finding out about how to use meta tags for search engines, I found that the only way I can make use of meta tags is to use redirection. E.G, using a blank index.htm with the meta tags for search and title, etc etc, and redirected to the php page using <meta http-equiv="REFRESH" content="0;url=index.php"> but.....search engines will ignore redirection, so that means that php pages can not be crawled, if this is the case, then I need to convert all my php pages into html.

the php site can be checked out at there is only one page that makes use of mixed html and php, but that's only part of the template used, the main index file is pure php.

Does anybody know how I can use html meta tags (or a php equivelant) in a php script?
 
huh?

php is not a problem for SEs. however meta redirects are.

you use metas exactly as you would in HTML. If your page is entirely scripted then use
Code:
//doctype goes here scripted or included
echo "<html>"
echo "<head>"
echo "<title>"
echo "Your page title goes here"
echo "</title>"
echo "<meta name=' ' content=' ' />"

//... rest of code

you can pull the content from a database or have it as a constant / variable.

PHP (and ASP) are both processed by the server before being sent to the browser / crawler. Your output from the PHP code is HTML, so what they see is what you would see by doing view source on the page in the browser.

Oh and BTW, meta tags are mostly useless for rankings in the SEs.

forum828 SEO.



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
the code doesn't work, I get:-

Parse error: parse error, unexpected T_ECHO, expecting ',' or ';' in C:\pchelp\index.php on line 24

Line 24 = echo "<head>"

I tried the code at the beginning of the file after '<?php' and in the middle, it's the same error but different line number.
 
Every PHP line must be ended by a ; (semicolon).

I'm sure ChrisHirst was just giving you a quick example, but every line in his example must be followed by a ;

[tt]
//doctype goes here scripted or included
echo "<html>";
echo "<head>";
echo "<title>";
echo "Your page title goes here";
echo "</title>";
echo "<meta name=' ' content=' ' />";

//... rest of code
[/tt]

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
The code wasn't intended to be used directly (no semicolons at line ends), more as an example of one option open to you.

Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top