javascript 谷歌抓取——显示:无和显示:阻止
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12482624/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
google crawl -- display:none & display:block
提问by chicharito
When google crawls a web page , do google bot crawl
当谷歌抓取网页时,做谷歌机器人抓取
content with code like
style="display:none"
content with code like
style="display:block"
带有代码的内容,例如
style="display:none"
带有代码的内容,例如
style="display:block"
the question i am asking because i have a website of F&Qs.
我问这个问题是因为我有一个 F&Q 网站。
For user i want answers to be displayed only when he clicks on "answer/solution" link.
For google bot i want solution section to be crawled else my content of page becomes too less.
对于用户,我希望仅当他单击“答案/解决方案”链接时才显示答案。
对于 google bot,我希望抓取解决方案部分,否则我的页面内容会变得太少。
采纳答案by zamnuts
Yes google will see content that is both display none and display block
是的,谷歌会看到既不显示又显示块的内容
Your FAQ section will be seen by google bots.
谷歌机器人会看到您的常见问题解答部分。
See these articles:
请参阅这些文章:
Webmaster Guidelines: http://support.google.com/webmasters/bin/answer.py?hl=en&answer=35769
网站管理员指南:http: //support.google.com/webmasters/bin/answer.py?hl=zh-CN& answer=35769
Use a text browser such as Lynx to examine your site, because most search engine spiders see your site much as Lynx would. If fancy features such as JavaScript, cookies, session IDs, frames, DHTML, or Flash keep you from seeing all of your site in a text browser, then search engine spiders may have trouble crawling your site.
使用文本浏览器(例如 Lynx)来检查您的站点,因为大多数搜索引擎蜘蛛会像 Lynx 一样查看您的站点。如果 JavaScript、cookie、会话 ID、框架、DHTML 或 Flash 等奇特功能使您无法在文本浏览器中看到您的所有网站,那么搜索引擎蜘蛛可能无法抓取您的网站。
Hidden text and links: http://support.google.com/webmasters/bin/answer.py?hl=en&answer=66353
隐藏文本和链接:http: //support.google.com/webmasters/bin/answer.py?hl=zh-CN& answer=66353
Hiding text or links in your content can cause your site to be perceived as untrustworthy since it presents information to search engines differently than to visitors. ... If you do find hidden text or links on your site, either remove them or, if they are relevant for your site's visitors, make them easily viewable.
在您的内容中隐藏文本或链接可能会导致您的网站被视为不可信,因为它向搜索引擎提供的信息不同于向访问者提供的信息。... 如果您确实在您的网站上发现隐藏的文本或链接,请将其删除,或者,如果它们与您网站的访问者相关,则使它们易于查看。
回答by dSquared
It is debatable if Google does crawl hidden elements; you'll find 'experts' who will argue one way or another, however most of it is pure conjecture. What I like to do in these situations is apply the display: none
via JavaScript / jQuery on $(document).ready()
that way the user gets the experience you are looking for, while Google indexes the page like so:
谷歌是否真的抓取隐藏元素值得商榷;你会找到“专家”,他们会以一种或另一种方式争论,但大部分都是纯粹的猜想。在这些情况下,我喜欢做的是display: none
通过 JavaScript / jQuery$(document).ready()
以用户获得您正在寻找的体验的方式应用,而谷歌则像这样对页面进行索引:
<div class="question">Does Google see this?</div>
<div class="answer">Yes is JS is used!</div>
$(document).ready(function(){
$('.answer').hide();
});
It is important to note that this method is also debatable as some have indicated that Google has started executing JS as part of the crawl. That being said, I've had good results using this technique.
需要注意的是,这种方法也值得商榷,因为有些人表示 Google 已经开始执行 JS 作为抓取的一部分。话虽如此,我使用这种技术取得了很好的效果。
I hope this helps!
我希望这有帮助!