Ajax 魔法:Kotaku 如何实现 Ajax *和* Google 可访问性?

发布于 2024-11-06 02:49:38 字数 944 浏览 0 评论 0 原文

Kotaku 推出了一款没有 hashbang 的新设计。他们的网站仍然明显使用 ajax 请求,但不知何故仍然可以通过 Google 找到它,并且内容显示在页面源中。他们是如何做到的?他们的文本似乎包含在脚本 type=text/javascript 中,但我不明白这会产生什么效果,也不明白他们为什么要这样做。 (当然,第一个页面请求可能只是触发一个静态的、服务器端构造的响应。但是检查其他文章,它确实通过 ajax 请求加载 json。没有页面刷新)

看看这个站点,例如:

http://kotaku.com/5800326/read-some-of -new-tomb-raider-game-right-now

没有哈希值,一个格式良好的 URL,它出现在 Google 中。我已经阅读了 Google Ajax 指南,据我了解,Google 仅当您使用 #! 时才请求 html 快照。在你的网址里面。

为了您的方便,我制作了一个屏幕截图,显示了 Chrome 调试器中文本的外观:(“ganjaAjaxContent”是什么意思?) 在此处输入图片描述

如果您搜索这篇文章,它是 Google 中的第一个匹配项: Google 搜索 Kotaku 文章

能够进行 ajax 而不必担心 Google 搜索,那就太好了。

Kotaku has launched a new design without hashbangs. Their site still clearly uses ajax requests, but somehow it is still found through Google and the content shows up in the pagesource. How do they do it? Their text seems to be contained inside a script type=text/javascript, but I don't understand what effect that has, or why they would do that.
(of course, the first page request may just trigger a static, serverside constructed response. But check other articles, it does load json through an ajax request. No page refresh)

Have a look at this site for example:

http://kotaku.com/5800326/read-some-of-new-tomb-raider-game-right-now

No hashes, a very well formed URL and it appears in Google. I have read the Google Ajax guide, and as far as I understand it, Google only requests an html snapshot iff you use #! inside your url.

For your convenience, I have made a screenshot that shows how the text looks inside the Chrome debugger: (what does "ganjaAjaxContent" mean?)
enter image description here

If you search for this article, it is the first match in Google:
Google search for Kotaku article

Being able to do ajax without having to worry about Google search would be excellent.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光病人 2024-11-13 02:49:38

Kotaku 和其他 Gawker 网站正在为 SEO 做很多事情:

所以你是对的,Google 的第一次访问加载语义化、可访问的服务器端构建的页面。虽然 Google可以抓取 hashbang 页面,但它不需要这样做,因为所有页面都通过 sitemap.xml 建立索引

希望这可以回答您的所有问题。

PS 话虽如此,hashbang 仍然对网络不利

Kotaku and the other Gawker sites are doing a number of things for SEO:

  • Submitting XML sitemaps for all of their content
  • Correct use of title and description tags for Google and Facebook

    • <title>Read Some of New Tomb Raider Game Right Now</title>
      <meta name="fragment" content="!">
      <meta name="title" content="Read Some of New Tomb Raider Game Right Now" />
      <meta name="description" content="Upcoming Tomb Raider reboot doesn't have a release date yet, but website Siliconera apparently has the game's script and published what's reportedly an excerpt from it. Check it out. [Siliconera]" />
      <meta property="og:title" content="Read Some of New Tomb Raider Game Right Now" />
      <meta property="og:description" content="Upcoming Tomb Raider reboot doesn't have a release date yet, but website Siliconera apparently has the game's script and published what's reportedly an excerpt from it." />
  • Displaying HTML post content when Javascript is turned off (inspect the <div class="post-body quick-post"></div> element)

So you're right, Google's first visit loads the semantic, accessible serverside-constructed page. WHile Google can crawl hashbang pages, it doesn't need to, because all of the pages are indexed via the sitemap.xml

Hope this answers all of your questions.

p.s. having said all this, hashbangs are still bad for the web

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文