【发布时间】:2012-11-25 03:17:19
【问题描述】:
我已将spiderable package 包添加到我的Meteor 应用程序中,当在url 中使用?_escaped_fragment_= 发出请求时返回页面的html 版本,但我无法让Google 抓取该网站。
详情
当在Google Webmaster Tools中使用Fetch as Google并请求根页面"http://example.com/"时,页面返回的是javascript版本;比如:
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>
问题
如何告诉 Google 将
?_escaped_fragment_=添加到 url,以便呈现 html 版本?如果网址不有 hashbang (!#),Google 是否仍会将
?_escaped_fragment_=添加到网址中?即/home、/products/1而不是/!#home、/!#products/1?如何让 Google 跟踪链接页面?并附加
?_escaped_fragment_=?该页面的所有 js 版本的标题中都有<meta name="fragment" content="!">。我认为这就是所有需要的。
似乎最简单的解决方案是更新可蜘蛛程序包以将 html 版本返回给 Google Bot,而不是要求 ?_escaped_fragment_=,但如果这对其他人有用,我很好奇,我我做错了。
附加信息
Meteor's spiderable package 是允许网络搜索引擎索引 Meteor 应用程序的临时解决方案。
根据source,它做了一些事情:
-
在js版页面的
head部分添加如下标签:<head><meta name="fragment" content="!"></head> -
使用PhantomJS解析javascript应用程序并在满足以下任一条件时返回一个html版本:
一个。请求用户代理是
"facebookexternalhit"b.请求的 url 包含字符串
?_escaped_fragment_=
【问题讨论】:
标签: javascript search-engine meteor google-search-console