从爬虫中排除特定区域

Exclude Specific Areas from Crawler

我想排除某些特定区域,使其不被 google 等抓取,因为这是 legal/privacy 并且会因为不相关的长文本而受到惩罚。所以我找到了 iframe 的解决方案。我认为最好的方法是在 robots.txt 中使用 htmlRouterenderRouteDisallow: /ROUTE/ 为我想要的元素创建一个特定的路由。或者有没有其他推荐的方法来解决这个问题?也许更优雅?

这是我尝试过的代码示例 <!--googleoff: index--> 但不幸的是,它不再起作用了:

<footer class="page-footer">
  <div class="footer-copyright">
    <div class="footer-container">

      {%- if data.global.legal -%}
        © {{ data.global.creation_date }} {{ data.global.copyright }}
      {%- endif -%}

      {%- if data.global.privacy -%}
        <a class="grey-text text-lighten-4 right modal-trigger" href="#modal-1">privacy</a>
        <div id="modal-1" class="modal">
          <div class="modal-content text-darken-4">

            <!--googleoff: index-->

            <h4>Privacy</h4>
            {{ apos.area(data.global, 'privacy', {
              edit: false,
              widgets: { 'apostrophe-rich-text': { } }
            }) }}

            <!--googleon: index-->

          </div>
        </div>
      {%- endif -%}

      {%- if data.global.legal -%}
        <a class="grey-text text-lighten-4 right modal-trigger" href="#modal-2">Legal</a>
        <div id="modal-2" class="modal">
          <div class="modal-content text-darken-4">

            <!--googleoff: index-->

            <h4>Legal Info</h4>
            {{ apos.area(data.global, 'legal', {
              edit: false,
              widgets: { 'apostrophe-rich-text': { } }
            }) }}

            <!--googleon: index-->

          </div>
        </div>
      {%- endif -%}

    </div>
  </div>
</footer>

我从撇号核心模块中选择了一些示例 renderRoute 函数并将其实现到我的撇号全局,现在我的撇号全局看起来像这样:

...
{
  name: 'legal',
  label: 'Legal Info',
  help: 'Your adress, phone and other info here',
  type: 'area',
  options: {
    widgets: {
      'apostrophe-rich-text': {
        toolbar: [
          'Styles',
          'Bold',
          'Italic',
          'Blockquote',
          'BulletedList',
          'Link'
        ],
        controls: {
          movable: false,
          cloneable: false,
          removable: true,
          position: 'top-right'
        }
       }
     }
   }
},
construct: function(self, options) {
  self.renderRoute('post', 'iframe', function(req, res, next) {
    return next(null, {
      template: 'legal'
    });
  });
}

但是当我打开合法模式时,我仍然没有得到像 iframe 这样的路由。我想我做错了什么或者没有完全理解这个功能。如果您能澄清这一点,我将不胜感激。也许这只是你的快速浏览...

googleoff 不适用于 public google 爬虫。仅供 google 的旧 "search appliance" 用于内网使用,已停产。

您的 iframe 策略可以奏效。到达那里的最简单方法是通过向 apostrophe-global 的架构添加一个区域来将内容放入全局首选项中,如下所示:

// in lib/modules/apostrophe-global/index.js

module.exports = {
  addFields: [
    {
      name: 'legal',
      type: 'singleton',
      widgetType: 'apostrophe-rich-text',
      options: {
        toolbar: [ 'Bold', 'Italic', 'Link' ]
      }
    }
  ]
};

然后您可以按照您的建议使用 renderRoute,并渲染一个模板,从全局文档中输出该区域。