Webmaster Forum


Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Share |
  #1 (permalink)  
Old 07-04-2011, 05:56 PM
Contributing Member
Latest Blog:
None

 
Join Date: 05-01-11
Posts: 57
iTrader: 0 / 0%
Meta data with included header

Hi,

I'm creating a new website and I'm using the PHP include function with my header to reuse it on new pages.

My problem is, if I use it like this on new pages:

PHP Code:
<?php include("header.php"); ?>
then my title, meta description and meta keywords will be the same since those are fixed in the header.php file.

So when i create a new page using the include function, how can I use title and meta data that is relevant to that page? I want these data to be different on each page.

Thanks
__________________
Drupal Themes
 
Reply With Quote
  #2 (permalink)  
Old 07-04-2011, 06:51 PM
HTMLBasicTutor's Avatar
Super Moderator
 
Join Date: 10-29-07
Location: British Columbia, Canada
Posts: 18,098
iTrader: 5 / 100%
Just put the typical parts of the header in the include and leave the title and meta data tags out of it.

If your header include includes the start of the web page, then I guess you need 2 head type includes, above the title and meta data and one for after them.
__________________

HTML Basic Tutor - Learn how to code for better SEO
Basic Computer Information - Computer & internet basics for website owners

SEO troubleshooting and review services available. - Pm me.
 
Reply With Quote
  #3 (permalink)  
Old 07-06-2011, 01:41 AM
JohnnyS's Avatar
Contributing Member
 
Join Date: 07-05-11
Location: philippines
Posts: 312
iTrader: 0 / 0%
You can declare a title,meta_keys,meta_desc variables before including the header.php, just like this...

PHP Code:
<?php 
$title 
"Page 1 title";
$meta_keys "key1,key2,key3";
$meta_desc "Page 1 description";
include(
"header.php");
?>
now in your header.php you need to echo those variables to their respective html tags..

header.php
PHP Code:
...

<title><?php echo $title?></title>
<meta name="keywords" content="<?php echo $meta_keys ?>" />
<meta name="description" content="<?php echo $meta_desc ?>" />

...
 
Reply With Quote
  #4 (permalink)  
Old 07-06-2011, 01:57 AM
Contributing Member
Latest Blog:
None

 
Join Date: 05-01-11
Posts: 57
iTrader: 0 / 0%
Thanks.
__________________
Drupal Themes
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SEO? dynamic meta data! synbitz SEO Forum 7 09-07-2010 12:39 AM
Using templates with duplicate meta data Cornbread SEO Forum 4 05-14-2007 07:58 PM
Google Using Meta Data Again? Angel69 Google Forum 7 10-12-2006 03:51 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 02:55 PM.
Powered by vBulletin
Copyright © 2000-2013 Jelsoft Enterprises Limited.
Copyright © 2003 - 2013 Escalate Media LP




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.