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
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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.