Jump to content

Different php meta tags for each page


bgbs

Recommended Posts

my header file contains the <head>  but I would like to have different meta tags displayed depending on the page being displayed.  I know you could insert <head> into each file and be done with it, but that may drive me nuts as the site grows.  So I'm trying to see how I can do it differently

 

So far I can do this with php

<?php

$meta_title="Site title goes here";

$meta_heading="Site heading info goes here";

$meta_desc="Site Description goes here";

$meta_keys="Site, Key, Words, Go, Here";

?>

Then I can call that meta tag by inserting this in the pages

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

 

I also have

$page=" unique page name"

inserted in each page.

 

I know this php meta script is incomplete, but what can I do to take it to the next level? Do I need to use and if statements, and how would I?

 

Thanks for all your help

 

-Ben

Link to comment
https://forums.phpfreaks.com/topic/204325-different-php-meta-tags-for-each-page/
Share on other sites

It depends where the values for the meta data will be comming from. If all your data is stored in a database then you could construct your meta tags based on the page you are accessing, again it all depends on where the meta data is comming from. Do you have a db table that might be able to construct the meta data?

I was thinking in the beginning to store values in the php file for now, and then upgrade to the database later.  I'm very new to php and I dont want to go over my head with this php construction.  I'm trying to take it one step at a time to master php capabilities.

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.