javascript - 为什么谷歌网站管理员工具看不到我网站的静态版本,而是动态版本的模板?

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

我添加了 spiderable package打包到我的 Meteor 应用程序,并在使用 ?_escaped_fragment_= 发出请求时返回页面的 html 版本在网址中,但我无法让 Google 抓取该网站。

详情

使用 Fetch as Google 时在 Google Webmaster Tools并请求根页面 "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 版本?

  • Google 是否仍会添加 ?_escaped_fragment_=到 url,如果 url 有 hashbangs (!#)?即 /home , /products/1而不是 /!#home , /!#products/1 ?

  • 如何让 Google 跟踪链接的页面?并附加 ?_escaped_fragment_= ?所有的js版页面都有<meta name="fragment" content="!">在标题中。我以为这就是所需的全部内容。

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

附加信息

Meteor's spiderable package is a temporary solution to allow web search engines to index Meteor applications.

根据source它做了一些事情:

  1. 它将以下标记添加到 head页面js版本的部分:

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

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

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

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

最佳答案

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

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

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

Not selected: Pages that are not indexed because they are substantially similar to other pages, or that have been redirected to another URL. More information.

EDIT2: 回应 Jonatan 的问题:

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

是的。我的应用程序不在 url 中使用 hashbangs (!#)。并且 Google 机器人在抓取时仍然附加 ?_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_=

的 url

关于javascript - 为什么谷歌网站管理员工具看不到我网站的静态版本,而是动态版本的模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13754712/

相关文章:

javascript - 如何在单击按钮时更改 View /模型?

php - 我需要具有一组特定功能的本地站点搜索

seo - 改进词典的内部链接结构

angular - 更改动态描述元标记可以用 Angular 8 中的搜索引擎检测到

css - 理解 CSS 类选择器在 meteor 中的使用

javascript - 使用谷歌地图删除路线

javascript - Angular2 - 未捕获的 ReferenceError : ng is not defined

javascript - 用 `this` 设置 `apply()` 的值

meteor - 我应该使用哪些 PayPal API 凭据才能上线?

javascript - 在两个静态 meteor 模板之间渲染路线的最佳方法?