I have a website in php, that pass certain php variables to javascript variables, google crawled me, which generates errors and duplicate content. Is there any way to make the google crawler to ignore the declaration of these variables in javascript?
echo '<script language="javascript">var '.$item['Nombre'].'="'.$descripcion.'";</script>';
Sorry for my english,
Google crawling javascript code and considering it duplicate? I have never heard of this problem before. Some of my pages have inlined javascript (if the content is small), that means the same <script>...</script>
on every page.
There are also cases where I output javascript variables more-or-less the same way you do. Google never marked it as "duplicate content".
Description from here:
Duplicate content generally refers to substantive blocks of content within or across domains that either completely match other content or are appreciably similar. Mostly, this is not deceptive in origin. Examples of non-malicious duplicate content could include:
- Discussion forums that can generate both regular and stripped-down pages targeted at mobile devices
- Store items shown or linked via multiple distinct URLs
- Printer-only versions of web pages
You can get this kind of errors if you have the same content on more than one of your pages, but google does not parse javascript as content. (Although you can never know for sure what google does or does not). The same way that google will not mark your <head>
tag as duplicate, or there is no penalty for having the same layout (menu, footer, etc) on every page.
You can put that <script>
tag in an <aside>
tag just to be sure.
The HTML Element represents a section of a page that consists of content that is tangentially related to the content around it, which could be considered separate from that content. Such sections are often represented as sidebars or as inserts. They often contain side explanations, like a glossary definition; more loosely related stuff, like advertisements; the biography of the author; or in web-applications, profile information or related blog links.
This means that the content will be more or less ignored by google when indexing the page. It will not mark it as a duplicate since it could be a commertial.
Also drop the language="javascript"
attribute from your script tags. I doubt that it would confuse google in any way, since that attribute is deprecated (use type
instead) and nothing takes it into account nowadays. But if google bot does, the correct value would be text/javascript
instead of simply javascript
. It is possible that google does not recognise the value javascript
and parses it as unknown type of text content.
The default type of the script is text/javascript
, so it is safe to omit.
Above all I suspect that the problem is not the existence of JS variables, but some other thing like GET parameters in your URL. GET parameters can be dealt with by configuring URL Parameters correctly in Webmaster Tools.