【问题标题】:Why google webmaster tools don't see the static version of my site but instead the template for the dynamic one?为什么谷歌网站管理员工具看不到我网站的静态版本,而是动态版本的模板?
【发布时间】: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 版本的标题中都有&lt;meta name="fragment" content="!"&gt;。我认为这就是所有需要的。

似乎最简单的解决方案是更新可蜘蛛程序包以将 html 版本返回给 Google Bot,而不是要求 ?_escaped_fragment_=,但如果这对其他人有用,我很好奇,我我做错了。

附加信息

Meteor's spiderable package 是允许网络搜索引擎索引 Meteor 应用程序的临时解决方案。

根据source,它做了一些事情:

  1. 在js版页面的head部分添加如下标签:

    &lt;head&gt;&lt;meta name="fragment" content="!"&gt;&lt;/head&gt;

  2. 使用PhantomJS解析javascript应用程序并在满足以下任一条件时返回一个html版本:

    一个。请求用户代理是"facebookexternalhit"

    b.请求的 url 包含字符串?_escaped_fragment_=

【问题讨论】:

    标签: javascript search-engine meteor google-search-console


    【解决方案1】:

    我认为这是一个“Google 网站管理员工具”错误。

    Google 似乎确实在抓取该网站 - 页面显示在 Google 结果中。然而,Google 网站管理员工具仍将总索引页面列为 1。但是,Bing 仍然没有抓取该页面。

    编辑: 它的谷歌网站管理员工具页面被列为

    未选择:由于与其他网页基本相似或已重定向到其他网址而未编入索引的网页。 More information.

    EDIT2:回应 Jonatan 的问题:

    如果 url 没有 hashbang (!#),Google 是否仍会将 ?_escaped_fragment_= 添加到 url?

    是的。我的应用程序没有在 url 中使用 hashbangs (!#)。并且 Google bot 在抓取时仍会附加 ?_escaped_fragment_=。以下是日志示例:

    INFO HIT /url/2/01 66.249.72.42
    INFO HIT /url/2/01?_escaped_fragment_= 66.249.72.142
    INFO HIT /url/2/01 108.162.222.82
    INFO HIT /url/2/01?_escaped_fragment_= 108.162.222.82
    INFO HIT /url/2/05 108.162.222.82
    INFO HIT /url/2/05?_escaped_fragment_= 108.162.222.214
    

    Google 机器人似乎会尝试带有和不带有 ?_escaped_fragment_= 的网址

    【讨论】:

    • 您的问题包含的问题多于此答案的答案。为什么它被标记为正确?您可以添加其他答案吗?特别是,我正在寻找Will Google still add the ?_escaped_fragment_= to the url, if the urls do not have hashbangs (!#)?的答案。
    • @JonatanLittke 我已经更新了答案。有趣的是,Google bot 会先尝试不带 ?_escaped_fragment_ 的网址,然后再尝试使用它。
    • 谢谢!我想这可能是因为片段元标记。我认为他们肯定不会在其他所有网站上这样做。
    • 那么为什么需要?_escaped_fragment_=?没有它,html 不会在来自curl 的响应中呈现
    • @Chet,仅当?_escaped_fragment_= 出现在 url 中时,可爬取程序包才会发送呈现的 HTML。呈现 HTML 是一个缓慢的过程,因此它不会只针对那些无法在客户端呈现 javascript 的请求执行每个请求。这能回答你的问题吗?
    【解决方案2】:

    任何没有以#! 开头的哈希片段的页面,例如主页,都需要这个:

     <meta name="fragment" content="!">
    

    通知爬虫获取丑陋的url(with _escaped_fragment_=)。显然它进入了&lt;head&gt; 部分。

    更新:我注意到根据您问题末尾给出的插件描述,添加了上述元标记,您可以通过显示源代码来检查它是否包含在您的页面中。

    通常除了主页之外的所有其他页面都应该在漂亮的 URL 中包含类似 www.yoursite.com/#!hashfragment 的内容,其中哈希后的 ! (#) 用作爬虫的通知器,因此您不需要包括上面提到的元标记。

    【讨论】:

    【解决方案3】:

    我知道这个问题已经得到解答,但对于从谷歌来回答这个问题的人来说。我想在这个主题上加入这个截屏视频。

    这帮助我理解了流星蜘蛛包。 https://www.eventedmind.com/tracks/feed-archive/meteor-the-spiderable-package

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-10
    • 2015-09-20
    • 1970-01-01
    • 2020-12-10
    • 1970-01-01
    • 2010-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多