Jump to content

to hide the keywords and discriptions

AEhsan's Photo
Posted May 13 2011 05:35 AM


I would like to know, how I could hide the keywords and discriptions in meta tags in HTML using PHP, that they will be hidden from the users but not from the search engines.


2 Subscribe

6 Replies

  rachel.j's Photo
Posted May 19 2011 07:20 AM

If you put the description and keyword meta tags in the head of the page they won't be displayed on the page, so users won't see them, but they will be accessible to search engines.

You page should be structured something like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

<meta name="Keywords" content="Your Keywords Here" />
<meta name="Description" content="Your Description Here" />

<title>Your Title Here</title>


Your Page Content Here


I hope this helps!
  AEhsan's Photo
Posted May 19 2011 09:15 AM

Hi Rachel,

I know that, the right place of the keywords are there. I should ask the question clearly. I mean how I could hide them that they won't be appear in source code text of the page, like php codes that they will be totally hidden for the udsers but not for the search engines.
  macnlos's Photo
Posted May 19 2011 09:46 AM

You can't do that. A PHP page is actually being interpreted, an HTML page is being rendered. If it's on the HTML page then it's on the page. It will always be on the source page, it may be on the displayed/rendered page.
Sent to you from my
iPad, iPhone, BlackBerry,
Laptop, Desktop, or
Kitchen Toaster
  mhalverson's Photo
Posted May 19 2011 01:10 PM

The only way I can think of doing it would be to use PHP to add them (or not) based on the headers sent, but it would potentially be very unreliable (I don't think there are standard headers used by search engine crawlers).

Something like:

<title>Test Page</title>
<?php if ($_SERVER['HTTP_USER_AGENT']=="some search engine crawler text") {?>
<meta name="Keywords" content="various keywords">
<?php }?>

Of course, they will be in the source page, but may or may not be in the page that the server serves depending on the headers sent by the requesting agent.

I suppose another way might be to have every page loaded through a server script that removes the keywords if it recognizes the requesting agent and doesn't otherwise. So pages are loaded through urls like loadpage.php?page=main.html. Of course, there are speed issues, security issues (which can be fixed) and other problems with that. I would trust this method even less than the other. In both cases, you will probably need to be able to reliably identify user agents from the headers.
  AEhsan's Photo
Posted May 20 2011 07:05 AM

Hi Mhalverson,

Thank you, it seems to be useful. I will try it and I will find out, if it won't be ignored by the search engines.
  Keith Douglas's Photo
Posted Mar 20 2013 02:14 AM

What is the advantage to hide keywords and descriptions for visitors?