Question

I have a template webpage that has a fixed header / footer. Depending on a body content to display, I need to change the content of meta tags in the the head.

After some googling, I learned that google crawler doesn't run any javascript codes and read php variables in pages. If so, will google crawler detect the following meta tags ignoring if statements?

<?php if(about page) ?>
    <meta ...>
    <meta ...>
    <meta ...>
<?php } else if(contact page) { ?>
    <meta ...>
    <meta ...>
    <meta ...>
<?php } and so on... ?>
Was it helpful?

Solution

From the way you've worded your question, as well as some of your comments, it sounds as though you're missing something very important.

PHP directives (like <?php if ...?>) are interpreted by the server. HTTP clients, such as web browsers and crawlers, only see the output of these directives; content that is not generated as output (e.g, because it is skipped by an if/else) is never sent to the client at all, so they cannot possibly detect it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top