我想排除某些特定区域,以免被Google等抓取,因为这是法律/隐私权,并且由于文本内容冗长,因此会受到处罚。因此,我找到了iframe解决方案。我认为最好的方法是使用robots.txt中的htmlRoute
或renderRoute
和Disallow: /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>
googleoff
不适合公开的Google搜寻器。严格来说,这是针对Google的旧“搜索设备”的,该设备已用于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
,并渲染一个从全局文档输出该区域的模板。