首页 > 解决方案 > 从爬虫中排除特定区域

问题描述

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

这是我尝试过的代码示例,<!--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 这样的路由。我想我做错了什么或者没有完全理解这个功能。如果您能澄清这一点,我将非常感激。也许这只是一个快速寻找你...

标签: apostrophe-cms

解决方案


googleoff不适用于公共谷歌爬虫。它严格用于谷歌的旧“搜索工具”,它是用于 Intranet 的,现已停产。

你的 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按照你的建议使用,并渲染一个从全局文档输出该区域的模板。


推荐阅读