hexo的seo优化之nofollow


优化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
2
3
4
5
nofollow:
enable: true
exclude:
- www.langzi.fun
- 友链地址

这样例外的链接不会加上nofollow

robots.txt文件

创建blog/source/robots.txt文件,加入如下内容

1
2
3
4
5
6
7
8
User-agent: * Allow: /
Allow: /archives/
Disallow: /vendors/
Disallow: /categories/


Sitemap: http://www.langzi.fun/sitemap.xml
Sitemap: http://www.langzi.fun/baidusitemap.xml

本文标题:hexo的seo优化之nofollow

文章作者:TTYONG

发布时间:2020年03月20日 - 15:03

最后更新:2020年05月17日 - 19:05

原始链接:http://tianyong.fun/hexo%E7%9A%84seo%E4%BC%98%E5%8C%96%E4%B9%8Bnofollow.html

许可协议: 转载请保留原文链接及作者。

多少都是爱
0%