使用集合让一切井井有条 根据您的偏好保存内容并对其进行分类。
调试网页
一般提示
请注意,在您发布了修正版内容之后,Google 不会立即抓取您的网页。因此,Search Console(和 Google 搜索)可能会继续显示您已修正的网页存在错误,直到 Google 再次抓取该网页时为止。有时候,您可以请求加速抓取(例如使用网址检查工具),但在大多数情况下,Google 要过几天才能注意到您网页中的更改。
下面这些实用的工具可以帮助您调试网页。
以下工具和报告要求:您必须是相应网页的经过验证的网站用户,才能在该网页或网站上使用此工具。这是因为,Search Console 提供的机密网站数据仅供经过验证的网站用户访问。
- Search Console - 注册 Search Console 并验证对网站的所有权,以便使用实用的网站监控和测试工具(例如下列工具)。
- “富媒体搜索结果状态”报告 - 了解 Google 可以或无法从您的网站读取哪些富媒体搜索结果、获取与排查富媒体搜索结果错误有关的信息,以及在修正所有问题后提交重新抓取请求。您无法使用此工具测试任意网址。
- 网址检查工具 - 了解您的网页在 Google 索引中的显示效果、测试实际网址的索引版本、了解 Google 如何呈现您的网页,以及提交网址以供编入索引。
- robots.txt 报告 - 检查 Google 能否处理您的 robots.txt 文件。此外,您还可以在紧急情况下请求重新抓取 robots.txt 文件。
- “AMP 状态”报告 - 查看 Google 检测到的整个网站范围内的 AMP 网页错误。错误是在常规抓取过程中检测到的;您无法测试任意网址。
这些工具可用于任何网址,无需使用者在 Search Console 中验证对相应网站的权限。 有些工具还允许将代码段粘贴到工具本身中。
如果您的网址设有防火墙,或者托管在本地计算机上,您可以使用隧道解决方案将网页提供给测试工具。了解如何测试本地托管的网页或设有防火墙的网页。
如需了解更多资源和咨询交流时间活动信息,请参阅我们的帮助页面。
测试本地托管的网页或设有防火墙的网页
Google 提供了多种测试工具来测试单个实际网页。例如,AMP 测试工具和富媒体搜索结果测试。 即使您的网页是在本地计算机上运行且无公开网址,或者是托管在防火墙后面,只要为测试工具提供一个指向您的网页的隧道,就仍然可以测试该网页。 这种做法在以下情况下可能有用:您希望在将某网页公开发布于网上之前测试该网页,或者想将测试网页作为发布流程中的另一个步骤。
如需测试本地网页或设有防火墙的网页,请使用隧道解决方案,例如 ngrok
。这些工具会提供一个公开网址,该网址会连接到您放在本地主机上或设有防火墙的服务器上的非公开网页。
以下示例首先启动 Python 的 SimpleHTTPServer
以将网页托管在本地计算机上,然后使用 ngrok 在一个可供公开访问的网址上提供该网页:
第 1 步
启动本地 HTTP 服务器以将您的网页托管在给定端口上。在我们的示例中,我们选择了端口 5326
。
SimpleHTTPServer
会将当前目录映射为网站根目录。
python3 -m http.server 5326
Serving HTTP on 0.0.0.0 port 5326 ...
第 2 步
在另一个终端上,启动本地 ngrok
应用,以监听我们在第 1 步中打开的端口 5326
。
./ngrok http 5326 --request-header-add ngrok-skip-browser-warning:1
ngrok by @inconshreveable (Ctrl+C to quit) Session Status online Version 2.2.4 Region United States (us) Web Interface http://127.0.0.1:4040 Forwarding http://ad0a5735.ngrok.io -> localhost:5326 Forwarding https://ad0a5735.ngrok.io -> localhost:5326 Connections ttl opn rt1 rt5 p50 p90 0 0 0.00 0.00 0.00 0.00
第 3 步
将您提供的 ngrok 网址传递给您选择的测试工具。
在我们的示例中,根网址为 http://ad0a5735.ngrok.io
,因此如果我们的网页保存到本地的 ~/testwebdir/mypage.html
,那么当我们从 ~/testwebdir/
启动上述服务器时,则可以测试 http://ad0a5735.ngrok.io/mypage.html
。 在富媒体搜索结果测试中,您可以直接粘贴该网址,也可以访问 https://search.google.com/test/rich-results/result?url=http%3A%2F%2Fad0a5735.ngrok.io%2Fmypage.html
。
请注意,不同的本地主机和隧道解决方案对网页的映射方式有所不同。
此外,一些隧道解决方案(非 ngrok)会使用 robots.txt 自动保护您的临时公开网址,这会阻止您对其运行 Google 测试。Google 测试工具受 robots.txt 制约。请阅读您的隧道解决方案和网站托管软件对应的文档。
调试访问错误
如果您在使用 Google 测试工具时遇到访问错误,请执行以下操作:
- 确保您的网页未受 robots.txt 保护且不需要登录。
- 尝试从防火墙外部、在另一台计算机上或使用 Chrome 以无痕模式访问您的网页。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-04。
[null,null,["最后更新时间 (UTC):2025-08-04。"],[[["\u003cp\u003eGoogle Search and Search Console may display errors even after you've fixed them, as crawling isn't immediate and can take a few days for changes to be reflected.\u003c/p\u003e\n"],["\u003cp\u003eUtilize various Google testing tools like the URL Inspection tool or Rich Results Test to debug and understand how Google perceives your pages.\u003c/p\u003e\n"],["\u003cp\u003eFor pages behind firewalls or hosted locally, use tunneling solutions like \u003ccode\u003engrok\u003c/code\u003e to expose them for testing with Google's tools.\u003c/p\u003e\n"],["\u003cp\u003eWhen facing access errors during testing, ensure your page isn't blocked by robots.txt, login requirements, or firewall restrictions.\u003c/p\u003e\n"],["\u003cp\u003eSearch Console offers valuable site monitoring and testing tools but requires site ownership verification for access to confidential data.\u003c/p\u003e\n"]]],["Google offers various tools for debugging web pages. Search Console, requiring site verification, provides tools like Rich Result status reports and the URL Inspection tool for in-depth analysis and recrawl requests. Anonymous tools, such as the AMP and Rich Results Tests, are available for any URL. To test locally-hosted or firewalled pages, utilize tunneling solutions like ngrok to create a public URL. If facing access errors ensure your page is not blocked by robots.txt and try accessing from another network or incognito mode.\n"],null,["Debugging your pages \n\nGeneral tips\n\n\nRemember that Google does not crawl your page immediately after you publish a fix. Therefore\n[Search Console](https://search.google.com/search-console) (and Google Search) can\ncontinue to show an error for a page that you have fixed\nuntil the page is crawled again. You can sometimes request an expedited crawl, for example\nusing the [URL Inspection](https://support.google.com/webmasters/answer/9012289)\ntool, but in most cases it takes a few days to notice changes in your pages.\n\nUseful testing tools\n\n\nHere are some useful tools to help you debug your pages.\n\nVerified site owner tools\n\n\nThe following tools and reports require you to be a\n[verified site user](https://support.google.com/webmasters/answer/9008080)\nfor the page in order to use this tool on that page or site. This is because Search Console\nprovides confidential site data that only a verified site user should have access to.\n\n- [Search Console](https://search.google.com/search-console) - Sign up for Search Console and [verify ownership of a site](https://support.google.com/webmasters/answer/9008080) to get access to useful site monitoring and testing tools, such as those listed below.\n- [Rich result status reports](https://support.google.com/webmasters/answer/7552505) - Learn which rich results Google could or couldn't read from your site, get troubleshooting information for rich result errors, and request a recrawl after you have fixed any problems. You cannot test an arbitrary URL using this tool.\n- [URL Inspection tool](https://support.google.com/webmasters/answer/9012289) - Learn how your page appears in the Google index, run an index test on a live URL, and see how Google renders your page, and submit a URL for indexing.\n- [Robots.txt report](https://support.google.com/webmasters/answer/6062598) - Check whether Google can process your robots.txt files. You an also request a recrawl of a robots.txt file for emergency situations.\n- [AMP status report](https://search.google.com/search-console/amp) - See AMP page errors for your entire site detected by Google. Errors are detected during the regular crawl; you cannot test an arbitrary URL.\n\nAnonymous tools\n\n\nThese tools can be used on any URL without needing Search Console permissions on the website.\nSome tools also allow code snippets pasted into the tool itself.\n\n\nIf your URL is behind a firewall, or is hosted on a local computer, you can use a tunnelling\nsolution to expose your page to the testing tool. [Learn how to test locally-hosted or firewalled pages.](#testing-firewalled-pages)\n\n- [AMP Test Tool](https://search.google.com/test/amp) - Test the validity of a specific AMP URL in real time.\n- [Rich Results Test](https://search.google.com/test/rich-results) - Test the validity of a structured data block in real time. The code can either be pasted into the tool, or hosted on a live page.\n\nMore tools\n\n\nSee [our help page](/search/help) for more resources and office hours information.\n\nTesting locally-hosted or firewalled pages\n\n\nGoogle provides several testing tools to test a single live web page. For example, the\n[AMP Test Tool](https://search.google.com/test/amp) and the\n[Rich Results Test](https://search.google.com/test/rich-results).\nHowever, if your page is running on your local machine without a public\nURL, or if it is hosted behind a firewall, you can still test the page by exposing a tunnel to\nyour page for the testing tool.\nThis can be useful if you want to test a page before making it publicly available on the web,\nor even as another step in your release process.\n\n\nTo test a local or firewalled page, use a tunneling solution such as `ngrok`. These\ntools provide a public URL that connects to a non-public page on your local host or firewalled\nserver.\n\n\nThe following example first starts up python's\n[`SimpleHTTPServer`](https://docs.python.org/2/library/simplehttpserver.html)\nto host a page on the local computer, then uses\n[ngrok](https://ngrok.com/) to expose that page on a\npublicly-accessible URL:\n\n**Step 1**\n\n\nStart up a local HTTP server to host your page on a given port. For our example we chose port\n`5326`.\n\n\n`SimpleHTTPServer` maps the current directory as the site root. \n\n python3 -m http.server 5326\n Serving HTTP on 0.0.0.0 port 5326\n ...\n\n\n**Step 2**\n\n\nOn another terminal, start up your local `ngrok` app, listening to port\n`5326`, which we opened in step 1. \n\n ./ngrok http 5326 --request-header-add ngrok-skip-browser-warning:1\n ngrok by @inconshreveable (Ctrl+C to quit)\n\n Session Status online\n Version 2.2.4\n Region United States (us)\n Web Interface http://127.0.0.1:4040\n Forwarding http://ad0a5735.ngrok.io -\u003e localhost:5326\n Forwarding https://ad0a5735.ngrok.io -\u003e localhost:5326\n\n Connections ttl opn rt1 rt5 p50 p90\n 0 0 0.00 0.00 0.00 0.00\n\n\n**Step 3**\n\n\nPass your exposed ngrok URL to the test tool of your choice.\n\n\nThe root URL in our example is `http://ad0a5735.ngrok.io`, so if our page is saved\nlocally at `~/testwebdir/mypage.html`, and we started the server above from\n`~/testwebdir/`, we could test `http://ad0a5735.ngrok.io/mypage.html`.\nIn the Rich Results Test, you could paste that URL in directly, or visit\n`https://search.google.com/test/rich-results/result?url=http%3A%2F%2Fad0a5735.ngrok.io%2Fmypage.html`.\n\n\nNote that different local hosts and tunneling solutions map your pages differently.\n\n\nAlso, some tunneling solutions (not ngrok) automatically protect your temporary public URL\nwith robots.txt, which will prevent you from running Google tests on them. Google testing\ntools respect robots.txt. Read the documentation for your tunneling solution and web hosting\nsoftware.\n\nDebugging access errors\n\n\nIf you get an access error using a Google testing tool:\n\n- Check that your page isn't protected by robots.txt and doesn't require a login.\n- Try accessing your page from outside your firewall, on another computer, or using Chrome in Incognito mode."]]