我已按照 Google 网站上的说明通过添加以下元标记在我的 AngularJS 网站上启用 Ajax 抓取:
<meta name="fragment" content="!">
呈现的内容有一些链接,如:
<a href="/user/1">User 1</a>
<a href="/user/2">User 2</a>
<a href="/user/3">User 3</a>
还有一些呈现动态内容的 Ajax 选项卡,例如:
<a href="#!/popular">Popular</a>
<a href="#!/recent">Recent</a>
查看服务器日志,GoogleBot 确实来了并正确传递了 Uri 中的 _escaped_fragement,这是正确的:
_escaped_fragment_=%2fpopular
_escaped_fragment_=%2frecent
问题是使用 site:www.somesite.com 查看实际的索引内容并在服务器上登录,我看到 GoogleBot 试图索引如下页面:
/user/1/#!/popular
/user/1/#!/recent
考虑到这些 URL 是相对的并且没有 #!在它们上指示 ajax 内容,有没有办法防止这种情况?
最佳答案
如果这些 URL 在所有页面上都可用,它会简单地添加它们。
所以,如果我想去:<a href="/user/1">User 1</a>
还有<a href="#!/popular">Popular</a>
有页面,那么谷歌加载是合乎逻辑的:/user/1#!/popular
您可能想知道我已经使用 Github 上的脚本解决了这个难题:https://github.com/kubrickology/Logical-escaped_fragment
只需使用以下命令构建您的 AJAX 页面:__init()
关于Ajax 内容索引,谷歌,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25440590/