hexo next 5.1.x主题底部添加备案信息

前言

    今天收到信息,博客备案工作终于完成了,按照法规,必须要在博客的主页展示备案号,否则会被工信部罚款😂。所以要在我的博客页脚添加备案号。我的next主题版本为5.1.x版本,但是网上收到到的解决方案都是基于6.x或者7.x版本的,next主题针对中国网站均需要备案的网络环境,在后续版本的_config.yml添加了beian字段,在相应的位置使能功能,再添加备案号才行。一开始我按着这个来做,怎么也不行,后面想到了直接在页脚添加备案号超链接的方式去做算了,现在记录一下方法,避免自己以后忘记了~~

修改过程

1、找到页脚配置文件

1
文件位置在 next/layout/_partials/

2、打开文件footer.swig并修改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<div class="copyright">{#
#}{% set current = date(Date.now(), "YYYY") %}{#
#}© {% if theme.footer.since and theme.footer.since != current %}{{ theme.footer.since }} — {% endif %}{#
#}<span itemprop="copyrightYear">{{ current }}</span>
<span class="with-love">
<i class="fa fa-{{ theme.footer.icon }}"></i>
</span>
<span class="author" itemprop="copyrightHolder">{{ theme.footer.copyright || config.author }}</span>

{% if theme.post_wordcount.totalcount %}
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-area-chart"></i>
</span>
{% if theme.post_wordcount.item_text %}
<span class="post-meta-item-text">{{ __('post.totalcount') }}&#58;</span>
{% endif %}
<span title="{{ __('post.totalcount') }}">{#
#}{{ totalcount(site, '0,0.0a') }}{#
#}</span>
{% endif %}
</div>

3、添加超链接

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<div class="copyright">{#
#}{% set current = date(Date.now(), "YYYY") %}{#
#}© {% if theme.footer.since and theme.footer.since != current %}{{ theme.footer.since }} — {% endif %}{#
#}<span itemprop="copyrightYear">{{ current }}</span>
<span class="with-love">
<i class="fa fa-{{ theme.footer.icon }}"></i>
</span>
<span class="author" itemprop="copyrightHolder">{{ theme.footer.copyright || config.author }}</span>

{% if theme.post_wordcount.totalcount %}
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-area-chart"></i>
</span>
{% if theme.post_wordcount.item_text %}
<span class="post-meta-item-text">{{ __('post.totalcount') }}&#58;</span>
{% endif %}
<span title="{{ __('post.totalcount') }}">{#
#}{{ totalcount(site, '0,0.0a') }}{#
#}</span>
{% endif %}
<span class="post-meta-divider">|</span>
<a href="http://beian.miit.gov.cn">粤ICP备2022028813号</a>
</div>

总结

    通过修改页脚swig文件,在指定的地方插入超链接即可。注意http://beian.miit.gov.cn工信部网址不能加www前缀,不然会出现错误。

0%