Is it possible to use PHP to create dynamic meta tags for SEO?

2

I would like to know if it is possible for me to use PHP in meta tags like description, keywords ...

I already use the title: <title><?php echo $titulo; ?> . Can I do the same on meta tags?

From:

<meta name="DESCRIPTION" content="descrição aqui, etc, etc...">

To:

<meta name="DESCRIPTION" content="<?php echo $descricao; ?>">
    
asked by anonymous 07.12.2015 / 01:24

2 answers

2

Response

You can use yes.

But why?

Both Google and any other search engine or browser will understand the data of MESMA so that it would understand if you defined the values directly in the HTML.

This is a basic PHP concept.

PHP is a server-side language, ie server-side wheel. Soon, before any HTML information is sent to anyone, it will be processed by the PHP module, which will generate a full HTML and then send it to the visitor / requester.

Do not you get it yet?

Let's illustrate.

  • The visitor accesses your domain and requests the index.php (or any other) file;
  • Your original index.php file is like this

    <?php
        $descricao = 'informatica, hospedagem, criação de sites, cloud';
    ?>
    <!DOCTYPE html>
    <html lang="pt-br">
    <head>
        <meta charset="utf-8">
        <title>Meu site - Menino sagaz</title>
        <meta name="description" <?php echo "content='" . $descricao . "'"; ?>>
    </head>
    <body>
        <h1>Olá, mundo!</h1>
    </body>
    </html>
    
  • Your server will receive the request and if it is a .php file, it will trigger the PHP module so that it interprets any and all PHP code in the file.
  • Then the PHP module does its job and turns its index.php file into it

    <!DOCTYPE html>
    <html lang="pt-br">
    <head>
        <meta charset="utf-8">
        <title>Meu site - Menino sagaz</title>
        <meta name="description" content='informatica, hospedagem, criação de sites, cloud'>
    </head>
    <body>
        <h1>Olá, mundo!</h1>
    </body>
    </html>
    
  • With file ready, it sends index.php to the visitor and everyone is happy.
  • PS: visitor can be anyone, be the visitor (ôh), Google, Bing and even Yahoo.

    Summarizing

    It does not matter if you made your site 100% using echo to generate the HTML's and content. The visitor will NEVER know how it was done, because he will always receive the ready file, already processed by the PHP module.

        
    09.12.2015 / 03:32
    1

    PHP as a back-end language will deliver the page rendered to your users and search engines. Resulting in the same content as you would reproduce manually.

        
    09.12.2015 / 03:29