我已将可蜘蛛程序包添加到我的 Meteor 应用程序中,并且在使用 url 发出请求时返回页面的 html 版本?_escaped_fragment_=
,但我无法让 Google 抓取该站点。
细节
在Google Webmaster Tools中使用Fetch as Google并请求根页面时,页面返回的是 javascript 版本;就像是:"http://example.com/"
HTTP/1.1 200 OK
content-type: text/html; charset=utf-8
date: Fri, 30 Nov 2012 05:39:36 GMT
connection: Keep-alive
transfer-encoding: chunked
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/e83157bdc4ff057fa3a20b82af4c11b4ebe776e7.css">
<script type="text/javascript">
__meteor_runtime_config__ = {"ROOT_URL":"http://www.example.com","DEFAULT_DDP_ENDPOINT":"https://www-example-com-ddp.meteor.com/"};
</script>
<script type="text/javascript" src="/13cf3d21ce1c4a88407ca5f3c250f186ab1738f9.js"></script>
<meta name="fragment" content="!">
<title>example.com</title>
</head>
<body>
</body>
</html>
如果相反,我请求http://example.com/?_escaped_fragment_=
返回 html 版本:
HTTP/1.1 200 OK
content-type: text/html; charset=UTF-8
date: Wed, 05 Dec 2012 02:44:09 GMT
connection: Keep-alive
transfer-encoding: chunked
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/e83157bdc4ff057fa3a20b82af4c11b4ebe776e7.css">
<title>example.com</title>
<meta name="viewport" content="initial-scale=1.0">
</head>
<body>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/one">One</a></li>
<li><a href="/two">Two</a></li>
</ul>
</body>
</html>
问题
你如何告诉谷歌添加
?_escaped_fragment_=
到 url,以便它呈现 html 版本??_escaped_fragment_=
如果 url没有hashbangs ( !# ), Google 是否还会将 url 添加到 url 中?即/home
,/products/1
而不是/!#home
,/!#products/1
?你如何让谷歌跟随链接的页面?并附加
?_escaped_fragment_=
? 页面的所有 js 版本都<meta name="fragment" content="!">
在页眉中。我认为这就是所有需要的。
似乎最简单的解决方案是更新可蜘蛛包以将 html 版本返回给 Google Bot,而不是要求?_escaped_fragment_=
,但如果这对其他人有用,我很好奇我做错了什么。
附加信息
Meteor 的可爬取程序包是一种临时解决方案,允许网络搜索引擎索引 Meteor 应用程序。
根据消息来源,它做了一些事情:
它将以下标签添加到
head
页面的 js 版本部分:<head><meta name="fragment" content="!"></head>
使用PhantomJS解析 javascript 应用程序并在满足以下任一条件时返回 html 版本:
一种。请求用户代理是
"facebookexternalhit"
湾。请求的 url 包含字符串
?_escaped_fragment_=