あなたは、ユーザーがどこにあるかに応じて、現在のページのタイトルを返し、その後、このようにそれを使用する方法を作成することができます。
<title><?php echo get_title(); ?></title>
キーワード
と同じ
<meta name="keywords" content="<?php echo get_keywords(); ?>" />
<meta name="description" content="<?php echo get_description(); ?>" />
実装では、あなたがウェブサイト上でナビゲートする方法に依存します。あなたが唯一のindex.php
持っている、と$_GET["page"]
によるコンテンツを選択した場合たとえば、あなたはこの
function get_title() {
switch($_GET["page"]) {
case "home":
return "Welcome to my home page";
case "guestbook":
return "Welcome to guestbook";
}
}
のようなものを持つことができるか、
function get_headers() {
// here set $title, $description and $keywords according to current page
// ....
// then just generate html
$html = "<title>$title</title>";
$html .= "<meta name='description' content='$description' />";
$html .= "<meta name='keywords' content='$keywords' />";
return $html;
}
のように一つにそれをすべて行うことができますし、再度ような何かを行いますこの
<head>
...
<?php echo get_headers(); ?>
...
ただし、各ページのタイトルとメタタグはどこですか? –
編集を参照してください、それは今明らかにする必要があります –