views:

49

answers:

4

hi, i use php for coding. is there a way to pass meta in the body part. so that it is recognized by serach engines. i know meta tags needs to be passed in head. but since i am generating pages dynamically . only body part get changed in every page.

+2  A: 

The html specs specify that meta tags belong in the head section of an HTML document.

You can generate the meta tags dynamically as well, just add them in the head section that you are outputting.

A php template will have head sections as well as body sections - just change them to output dynamic meta tags.

Oded
+2  A: 

<meta> tags must go in the <head> - per the HTML specification.

Refactor your templates so you will be able to add <meta> tags dynamically in the head. It shouldn't be a problem.

Yuval A
+1  A: 

You should go with specification, it shouldn't be that difficult to even generate the meta tags dynamically like you are doing for the body part.

You can also use the Simple HTML DOM to manipulate the html at any part of the page.

Sarfraz
A: 

You can use output buffering and renew meta-data using placeholders after generating page.
Like this:

<?php

function callback($buffer) {

  return (ereg_replace("meta", "<META blah-bla-bla />....", $buffer));

}

ob_start("callback");

?>

<html>
<head>meta</head>
<body>
<p>It's like comparing apples to oranges.
</body>
</html>

<?php

ob_end_flush();

?>
GOsha
-1 for using ereg
Maerlyn
corrected (4togo)
GOsha