Google dont display description in search results

Google renders the title as it should but it renders the description from the text on the page so all pages get the same description. I have been trying to find the error for several days but have not succeeded
This is the link that google reads from a file

Blockquote https://xxxx.com/index.php?id=något

This is a very short version of index.php

Blockquote<?php
ini_set(‘display_errors’, ‘0’);
session_start();
$recept = $_GET[‘idrec’];
$livsmedel = $_GET[‘id’];
// Conect to database and get the values i need
?>
<?php if (!empty($livsmedel)&& empty($recept)) { echo "Title nr 1 ";}
if (empty($livsmedel)&& !empty($recept)) { echo “Title nr 2 “;}
if (!empty($livsmedel)) { echo implode(’ ‘, array_slice(explode(’ ‘, $livsmedel), 0, 7));}
else { echo implode(’ ‘, array_slice(explode(’ ‘, $recept), 0, 7));}
if (empty($livsmedel) && empty($recept)) { echo “Title nr 3”;} ?>
<meta name=“description” content= "<?php if (!empty($livsmedel))
{ echo “description nr 1”; echo implode(’ ‘, array_slice(explode(’ ', $livsmedel), 0, 7)); echo " the rest of description nr 1” ; }
if (!empty($recept))
{ echo “description nr 2”; echo implode(’ ‘, array_slice(explode(’ ', $recept), 0, 7)); echo " the rest of description nr 2.” ; }?><?php if (empty($livsmedel) && empty($recept))
{ echo “description nr 3.”;} ?> ">

Google doesn’t see your PHP code; all it sees is the HTML your code produces. Regarding what parts of your text appear: Google automatically attempts to extract the part of the page that’s most relevant to the user’s query.

But Google can see the PHP code in the title so why not in the description.

That makes no sense! PHP is client-side only. Google can not see it. Google only sees the OUTPUT of your webpage. And, if you keep the title or description, it must show in your posted (meaning output of web server) page that the browser sees.

Look at your final output page. RIGHT-CLICK on it and VIEW-SOURCE. You will never see any PHP there unless you posted code on it for some reason. But, Google never looks at the code, just the final page that goes into the browser. Hope that makes sense to you.

If I RIGHT-CLICK on VIEW-SOURCE can I see the title and description in the browser as it should be. But of course I can not see the PHP code. Shouldn’t Google see what the browser perceives.

Yes, Google will see whatever you can see if you use VIEW-SOURCE.
In there, you need to make sure that the < HEADER> tags are correct for the TITLE and DESCRIPTION.
If they are, then Google will see them and scrape them. If you use the same TITLE and DESC on all pages, then your entire site will have those locked into the Google versions.

Also, there are tools on Google’s developer areas that can make it re-scan your site for errors and for these items.

Here is what Google sees for the very page you are looking at now:
< title>Google dont display description in search results - General PHP Help - PHPHelp< /title>
< meta name=“description” content=“Google renders the title as it should but it renders the description from the text on the page so all pages get the same description. I have been trying to find the error for several days but have not succeeded
This is &hellip;”>

I’ll check what you suggest and see what I find. I will let you know how it goes. I will probably have to request a new indexing of the site so it may take a few days before I know the result.
Thanks for the advice.

There is nothing wrong with the code but I saw that some of my 2000 pages had the correct description.
I found an article where I could read that Google Rewrites Meta Descriptions.
Portent analyzed mobile and desktop search results to find Google rewrites meta descriptions at a rate of 71% on mobile, and 68% on desktop.

That is interesting! But, if you view-source and look at all the meta’s and then google your search, is the data the same or different…

Also, remember Google is a paid site and for unpaid members, they do what THEY want with the data they find on the internet. Suks, but, that is life with Google… I would compare your data and what Google has for you and if different, you can contact them.

Google has changed the description to the correct one of about 200 pages. I probably do not need to do anything because it resolves with time ,.

Probably! They rescan sites often, but, they have billions so it takes time for them to catch up to a lot of sites. Good luck going forward!

Sponsor our Newsletter | Privacy Policy | Terms of Service