更好地了解网页
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
2014年5月30日星期五
1998年
,当我们的服务器在
苏珊·沃西基
(Susan Wojcicki)的车库中运行时,我们完全没必要担心JavaScript或CSS的问题。当时,它们还没有得到广泛应用,JavaScript也只是用于开发网页元素。但眨眼间,情况便发生了翻天覆地的变化。现在,网络中随处可见大量地运用了JavaScript的丰富多彩、美轮美奂的动态网站。今天,我们将讨论Google在呈现更丰富多彩的网站方面的能力(这意味着我们在您的网站上看到的内容更像是现代网络浏览器呈现的内容),其中包括外部资源、执行JavaScript和应用CSS。
以往,我们只关注在HTTP响应主体中获取的原始文本内容,并不会实际解译运行JavaScript的标准浏览器会看到的内容。如果网页中包含由JavaScript呈现的高价值内容,那么当该网页开始显示时,我们无法让搜索者知道,这对于搜索者和网站站长来说都不是想要的结果。
为了解决这个问题,我们决定尝试通过执行JavaScript来了解网页。在当前网络规模下这一点很难做到,但我们认为这非常值得一试。一段时间以来,我们一直在逐步改善这一问题的处理方式。在过去的几个月中,我们的索引系统一直在像普通用户采用的启用了JavaScript
的浏览器一样呈现大量网页。
有时,呈现过程并非尽善尽美,这会给与您网站有关的搜索结果带来负面影响。下面,我们列出了一些潜在的问题,以及在可能的情况下如何避免这些问题的发生:
-
如果单独文件中的JavaScript或CSS等资源被屏蔽(例如通过robots.txt),从而导致Googlebot无法检索这些资源,那么我们的索引系统将无法像普通用户那样看到您的网站。我们建议您允许Googlebot检索JavaScript和CSS,以便我们可以更好地将您的内容编入索引。这一点对于移动网站来说尤为重要,因为CSS和JavaScript等外部资源有助于我们的算法了解相应网页
已针对移动设备进行优化
。
-
如果您的网络服务器无法处理资源抓取请求,则可能会妨碍我们呈现您的网页。如果您想要确保Google可以呈现您的网页,请确保您的服务器能够处理资源抓取请求。
-
适当地将网站降级通常不失为一种非常好的方法。即使用户的浏览器没有兼容的JavaScript实现功能,这也有助于用户畅享您提供的内容。此外,这种方法还有利于停用或关闭了JavaScript的访问者以及尚无法执行JavaScript的搜索引擎。
-
有时,JavaScript可能会因为对于我们来说过于复杂或难以理解而无法执行,在这种情况下,我们将无法完整、准确地呈现相应网页。
-
有些JavaScript会移除网页中的内容(而非添加内容),这会导致我们无法将相应内容编入索引。
为了使问题更易于调试,目前我们正在开发一种工具,以便帮助网站站长更好地了解Google如何呈现其网站。我们非常期待不久后在
网站站长工具
中为您提供此工具。
如有任何疑问,请随时访问我们的帮助论坛。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2014-05-01。
[null,null,["最后更新时间 (UTC):2014-05-01。"],[[["\u003cp\u003eGoogle's indexing system is now rendering a significant number of web pages with JavaScript enabled to better understand dynamic content.\u003c/p\u003e\n"],["\u003cp\u003eWebmasters should ensure Googlebot can access JavaScript and CSS files to facilitate proper rendering and indexing, particularly for mobile websites.\u003c/p\u003e\n"],["\u003cp\u003eWebsites should be designed to degrade gracefully for users and search engines that may not have JavaScript capabilities, ensuring content accessibility.\u003c/p\u003e\n"],["\u003cp\u003ePotential issues with rendering may include server overload due to crawl requests, overly complex JavaScript, and JavaScript removing content, which webmasters should address.\u003c/p\u003e\n"],["\u003cp\u003eGoogle is developing a tool in Webmaster Tools to aid webmasters in understanding how Google renders their websites.\u003c/p\u003e\n"]]],["Google's indexing system now renders web pages more like a typical browser, including executing JavaScript and applying CSS. Key actions include allowing Googlebot to retrieve JavaScript and CSS resources, ensuring servers can handle crawl requests, and having sites degrade gracefully. Complex or content-removing JavaScript can hinder indexing. A tool is in development to help webmasters understand how their site is rendered, and the team recommends checking the help forum.\n"],null,["# Understanding web pages better\n\nFriday, May 23, 2014\n\n\nIn [1998](https://www.google.com/about/company/history/) when our\nservers were running in\n[Susan Wojcicki](https://twitter.com/SusanWojcicki)'s garage, we\ndidn't really have to worry about JavaScript or CSS. They weren't used much, or, JavaScript was\nused to make page elements... blink! A lot has changed since then. The web is full of rich,\ndynamic, amazing websites that make heavy use of JavaScript. Today, we'll talk about our\ncapability to render richer websites---meaning we see your content more like modern Web\nbrowsers, include the external resources, execute JavaScript and apply CSS.\n\n\nTraditionally, we were only looking at the raw textual content that we'd get in the HTTP response\nbody and didn't really interpret what a typical browser running JavaScript would see. When pages\nthat have valuable content rendered by JavaScript started showing up, we weren't able to let\nsearchers know about it, which is a sad outcome for both searchers and webmasters.\n\n\nIn order to solve this problem, we decided to try to understand pages by executing JavaScript.\nIt's hard to do that at the scale of the current web, but we decided that it's worth it. We have\nbeen gradually improving how we do this for some time. In the past few months, our indexing system\nhas been rendering a substantial number of web pages more like an average user's browser with\nJavaScript turned on.\n\n\nSometimes things don't go perfectly during rendering, which may negatively impact search results\nfor your site. Here are a few potential issues, and---where possible,---how you can help\nprevent them from occurring:\n\n- If resources like JavaScript or CSS in separate files are blocked (say, with robots.txt) so that Googlebot can't retrieve them, our indexing systems won't be able to see your site like an average user. We recommend allowing Googlebot to retrieve JavaScript and CSS so that your content can be indexed better. This is especially important for mobile websites, where external resources like CSS and JavaScript help our algorithms understand that the pages are [optimized for mobile](/search/docs/crawling-indexing/mobile/mobile-sites-mobile-first-indexing#crawling_requirement).\n- If your web server is unable to handle the volume of crawl requests for resources, it may have a negative impact on our capability to render your pages. If you'd like to ensure that your pages can be rendered by Google, make sure your servers are able to handle crawl requests for resources.\n- It's always a good idea to have your site degrade gracefully. This will help users enjoy your content even if their browser doesn't have compatible JavaScript implementations. It will also help visitors with JavaScript disabled or off, as well as search engines that can't execute JavaScript yet.\n- Sometimes the JavaScript may be too complex or arcane for us to execute, in which case we can't render the page fully and accurately.\n- Some JavaScript removes content from the page rather than adding, which prevents us from indexing the content.\n\n\nTo make things easier to debug, we're currently working on a tool for helping webmasters better\nunderstand how Google renders their site. We look forward to making it to available for you in the\ncoming days in\n[Webmaster Tools](https://search.google.com/search-console).\n\nIf you have any questions, please you can visit our help forum.\n\n\nPosted by Erik Hendriks and [Michael Xu](https://www.linkedin.com/in/michaelxu1999/), Software Engineers, and\n[Kazushi Nagayama](https://plus.google.com/+KazushiNagayama/?rel=author),\nWebmaster Trends Analyst"]]