0
votes

My index page has several different parameters, each of which shows different, but similar content.

For example, I have the following pages:

index.php?page1
index.php?page2
index.php?page3

Is it possible to set specific meta tags for each type of page, even though they all link to index.php?

For example, can I set a specific description meta tag for page1, another for page2, and another for page3 so that Google can crawl the site, yet receive different meta tags for each parameters.

3
@reenleedr That's not at all helpful. - user4171336

3 Answers

0
votes

Yes, you can.

As long as you're able to identify which parameter is passed, you can customize the output however you want.

0
votes

You could check to see if the $_GET index for that request is set by using:

if(isset($_GET['page1']) {
    // set metadata for page 1 ie:
    echo '<meta name="description" content="This is Page 1">';
} else if(isset($_GET['page2']) {
    // set metadata for page2 ie:
    echo '<meta name="description" content="This is Page 2">';
} else if(isset($_GET['page3']) {
    // set metadata for page 3 ie:
    echo '<meta name="description" content="This is Page 3">';
}
0
votes

If you need to have other meta tags other than description, then you can do the following

$meta_tags = array("page1" => array("author" => "author 1", "description" => "description 1"), "page2" => array("author" => "author 2", "description" => "description 2"));
foreach($meta_tags as $page => $meta)  {
    if(isset($_POST[$page])) {
        foreach($meta as $name => $value) {
            echo '<meta name="$name" content="$value">';
        }
     }
 }

This seems like a better approach to me than what Kypros is suggesting due to less lines of code and not having to write a lot of IF conditions