I have the structure of the document:
<?
include('head.php');
include('header.php');
include('index_content.php');
include('footer.php');
include('form.php');
include('js.php');
?>
When I create a new page, I use this skeleton and change only the page content. But for SEO optimization it is also necessary to change the title and meta tags. Is it possible to change this dynamically using JavaScript depending on the page. Or is it better not to bathe and write something like this:
<?
include('head.php'); //beginning of the <head> tag
?>
<title>Some title</title>
<meta name="description" content="some description">
<meta name="keywords" content="some keywords">
<?
include('header.php'); - //end of </head> tag
include('index_content.php');
include('footer.php');
include('form.php');
include('js.php');
?>
You can directly get the php
variable into meta
tag as shown below.
<?
include('head.php'); //beginning of the <head> tag
?>
<title>Some title</title>
<meta name="description" content="<?php echo $DESCRIPTION;?>">>
<meta name="keywords" content="<?php echo $KEYWORDS;?>">>
<?
include('header.php'); - //end of </head> tag
include('index_content.php');
include('footer.php');
include('form.php');
include('js.php');
?>
UPDATE
If you use jquery, this might work
$("meta[name='description']").attr("content","<?php echo $DESCRIPTION;?>");