大网数据广告活动
网站运营与故障问答

Ajax Request with Push State to Current URL SEO Friendly?

· 52CE 我爱测

After reading up on getting content indexed in Google that is pulled into a page from an AJAX request, I have found that you can use pushState to change the URL and this will allow Google to find it. My question is can you pushSt…

问题原文

原帖链接 · Paul · CC BY-SA 4.0

After reading up on getting content indexed in Google that is pulled into a page from an AJAX request, I have found that you can use pushState to change the URL and this will allow Google to find it.

My question is can you pushState as the current URL and this still work. So for example on the home page of the site, make your AJAX request then push state without parameters?

window.history.pushState('','','');

已采纳解答

原帖链接 · Stephen Ostermiller · CC BY-SA 4.0

You do not need to use pushState to get Google to index content that is loaded into the page via AJAX when the URL doesn't change. There is no need to use pushState at all in this instance.

To get Google to index a site that is fully powered by AJAX you need to:

  • Create separate URLs for each piece of content and use pushState to change the URL for human visitors as they navigate the site.
  • Make sure that when a visitor starts on a deep URL, the correct content is loaded.
  • Make sure that Googlebot can crawl all the content on the site by providing <a href links to all the URLs within the site. For human visitors, you can intercept clicks on these links, use AJAX to load the content, and use pushState to change the URL appropriately.

Using pushState is never required for Googlebot. pushState is required for human visitors so that they can:

  • Create bookmarks to sections of your site
  • Keep the AJAX experience even when they perform actions that would normally cause page loads like clicking on links.

There is no need to use pushState on the landing page before any clicks happen. In fact, doing so might prevent Googlebot from indexing your content correctly. You should only use pushState as visitors transition to different content. Googlebot will load and render AJAX calls that are required during the onload event of the page. There doesn't need to be (and shouldn't be) a pushState call to make that happen.

The only caveat is that it takes Googlebot longer to render pages than the initial static content Googlebot crawl. Googlebot may crawl your site and find that it requires AJAX. Your page will get put in the render queue. It may take Googlebot up to two months to come back and get the AJAX for that page and perform the rendering. Only once your page is rendered will Google index the content of a page that requires AJAX to load the content. Pages that require AJAX and rendering will be indexed more slowly and it will take Google longer to see updates to them.

Other search engines (Bing, Yandex, and Baidu) do not have bots as advanced as Googlebot. They probably won't be able to index pages that require JavaScript to load the content.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2019-06-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。