我构建了一个 Angular SPA。我的一些 head
代码如下所示:
<!--title-->
<title ng-bind="$root.title"></title>
<!--web-->
<meta name="application-name" content="{{$root.site.name}}">
<meta name="description" content="{{$root.page.description}}">
<!--facebook-->
<meta property="og:type" content="website">
<meta property="og:title" content="{{$root.page.title}}">
<meta property="og:url" content="{{$root.site.url}}">
<meta property="og:image" content="{{$root.site.url}}/framework/img/brand/facebook.jpg">
<meta property="og:description" content="{{$root.page.description}}">
<!--twitter-->
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="{{$root.page.title}}">
<meta name="twitter:url" content="{{$root.site.url}}">
<meta name="twitter:image" content="{{$root.site.url}}/framework/img/brand/social.jpg">
<meta name="twitter:description" content="{{$root.page.description}}">
<!--routing-->
<base href="/">
<meta name="fragment" content="!">
出于 SEO 的目的,我已将应用程序设置为识别带有转义片段 ?_escaped_fragment_=
的请求。当这些请求通过时,它会提供页面的预渲染版本。
每个搜索机器人都会使用转义片段吗?例如,如果我在 Facebook 上发布指向我的 SPA 页面的链接,它会获取该页面的预渲染版本还是未渲染版本?
Facebook 应该希望转到该页面,查看片段元标记并了解它是一个 ajax 应用程序,然后重新访问包含转义片段的页面以接收预渲染的内容。
最佳答案
看来对 Crawlable Ajax 规范的支持并不完善。有些搜索机器人支持,有些则不支持。
- Google: Yes
- Bing: Yes
- Yandex: Yes
- Facebook (open graph reading bot): Only for hashbang URLs
- Twitter Cards bot: No
- Google+ bot: Yes
- LinkedIn bot: No
(罗伯特·邓恩(Robert Dunne)在此处的评论中总结了上述内容:http://builtvisible.com/javascript-framework-seo/)
可以在这里找到解释这一点的更详细的帖子:
http://blog.ajaxsnapshots.com/2013/11/googles-crawlable-ajax-specification.html
幸运的是,有一些方法可以检测不支持 CAS 的搜索机器人,并强制将 ?escaped_fragment_=
放入网址中,以将它们定向到元标记填充的快照(预渲染)页面内容!
可以在此处找到执行此操作的各种配置的说明: https://ajaxsnapshots.com/configGuide
关于javascript - 所有搜索机器人都使用转义片段吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29259222/