Jump to content

Meta Tags as Variabls


Talon21

Recommended Posts

Hi all,

 

I'm in the middle of building a new web site, and since I'm into SEO I would to use meta tags (title,keywords,desciption, etc...)

The idea is like that, to use two different files for one page, for example:

for the page about-us.php I will create one file called "about-us.php" under the folder /htdocs/ this file will held the meta tags as variables and of curse I will include the appropriate template.

on the on the other file under the folder "content" I will create another "about-us.php" that will held the content.

What will the two files should look like? thanks for your help.

Link to comment
https://forums.phpfreaks.com/topic/113459-meta-tags-as-variabls/
Share on other sites

I think you're looking for includes.

 

So your content file would be the main page that people go to:

<html>
  <head>
    <?php include(/path/to/file/about_us.php); ?>
  </head>
  <body>
     ...content...
  </body>
</html>

 

The include calls the path to the file holding your meta tags.

 

In the meta tag version:

<?php

echo '<meta etc... />
      <meta etc... />';

?>

 

Hope that helps!

You can use includes to include content as well...

 

For example in your sub.php, between the body tags, you can include content as well:

 

<body>
  <?php include('/path/to/file/about_us.php'); ?>
</body>

 

Then the about_us.php file could hold only the content.

 

Are you using a single sub.php page for all of your non-index pages? If that's the case, you could use GET variables to choose which content will show.

 

Example:

mysite.com/sub.php?page=aboutus

<body>
<?php
if ($_GET['page'] == 'aboutus') {
  include('about_us.php');
} elseif ($_GET['page'] == 'contact') {
  include('contact_us.php');
}
?>
</body>

 

Hope that clears it up...

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.