修改Hexo Next主题页脚备案

此方法比较暴力,只适合临时用或者只需要萌备案可以参考。
已参照官方文档重写了页脚,萌备案请参考新发布的文章。

查看文章

修改footer.njk

将代码:

footer.njk
1
2
3
4
5
6
7
8
9
10
11
{%- if theme.footer.beian.enable %}
<div class="beian">
{{- next_url('https://beian.miit.gov.cn', theme.footer.beian.icp + ' ') }}
{%- if theme.footer.beian.gongan_icon_url %}
<img src="{{ url_for(theme.footer.beian.gongan_icon_url) }}" alt="">
{%- endif %}
{%- if theme.footer.beian.gongan_id and theme.footer.beian.gongan_num %}
{{- next_url('https://beian.mps.gov.cn/#/query/webSearch?code=' + theme.footer.beian.gongan_id, theme.footer.beian.gongan_num + ' ') }}
{%- endif %}
</div>
{%- endif %}

修改为:

footer.njk
1
2
3
4
5
6
7
8
9
10
{%- if theme.footer.beian.enable %}
<div class="beian">
{%- if theme.footer.beian.gongan_icon_url %}
<img src="{{ url_for(theme.footer.beian.gongan_icon_url) }}" alt="">
{%- endif %}
{%- if theme.footer.beian.gongan_id and theme.footer.beian.gongan_num %}
{{- next_url('https://icp.gov.moe/?keyword=' + theme.footer.beian.gongan_id, theme.footer.beian.gongan_num + ' ') }}
{%- endif %}
</div>
{%- endif %}

修改Next主题的_config.yml

将属性:

_config.yml
1
2
3
4
5
6
beian:
enable: false
icp:
gongan_id:
gongan_num:
gongan_icon_url:

修改为:

_config.yml
1
2
3
4
5
6
beian:
enable: true
# icp:
gongan_id: XXXXXXXX
gongan_num: 萌ICP备XXXXXXXX号
gongan_icon_url:

添加萌备案的图标(可选)

  1. 下载图标包,将moe-icon文件夹解压到source文件夹下。
  2. 打开Next主题footer的样式文件,修改页脚icon大小,参考路径:

    themes\hexo-theme-next\layout_partials\footer.njk

  3. 搜索if (hexo-config('footer.beian.enable') and hexo-config('footer.beian.gongan_icon_url'))
  4. 将这段代码修改成以下这样(其实只是设定了下图标大小):
footer.njk
1
2
3
4
5
6
7
8
9
if (hexo-config('footer.beian.enable') and hexo-config('footer.beian.gongan_icon_url')) {
.beian img {
display: inline-block;
margin: 0 3px;
vertical-align: middle;
width: 20px;
height: 20px;
}
}
  1. 在上一步中的属性gongan_icon_url中添加./moe-icon/icon120.png
  2. 完成。