优化nofollow
给非友情链接的出站链接添加 “nofollow” 标签,nofollow标签是由谷歌领头创新的一个“反垃圾链接”的标签,并被百度、yahoo等各大搜索引擎广泛支持,引用nofollow标签的目的是:用于指示搜索引擎不要追踪(即抓取)网页上的带有nofollow属性的任何出站链接,以减少垃圾链接的分散网站权重。
找到themes\next\layout_partials\footer.swig文件的:
1 | {{ __('footer.powered', '<a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a>'}} |
改成:
1 | {{ __('footer.powered', '<a class="theme-link" target="_blank" href="https://hexo.io" rel="external nofollow>Hexo</a>') }} |
将下面代码:
1 | <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next"> |
改成:
1 | <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next" rel="external nofollow"> |
修改sidebar.swig文件,在themes\next\layout_macro,将下面代码:
1 | <a href="{{ link }}" target="_blank">{{ name }}</a> |
改成:
1 | <a href="{{ link }}" target="_blank" rel="external nofollow">{{ name }}</a> |
将下面代码:
1 | <a href="http://creativecommons.org/licenses/{{ theme.creative_commons }}/4.0" class="cc-opacity" target="_blank"> |
改成:
1 | <a href="http://creativecommons.org/licenses/{{ theme.creative_commons }}/4.0" class="cc-opacity" target="_blank" rel="external nofollow"> |
安装nofollow插件
减少出站链接能够有效防止权重分散,hexo有很方便的自动为出站链接添加nofollow的插件。
1 | npm install hexo-autonofollow --save |
在站点配置文件加入:
1 | nofollow: |
这样例外的链接不会加上nofollow
robots.txt文件
创建blog/source/robots.txt文件,加入如下内容
1 | User-agent: * Allow: / |