0%

NexT主题设置

NexT主题安装

NexT主题官网: http://theme-next.iissnan.com/

最新版本NexT的GitHub地址: https://github.com/theme-next/hexo-theme-next

  1. 下载新的主题包

    1
    2
    3
    cd C:\blog

    git clone https://github.com/theme-next/hexo-theme-next themes/next
  2. 修改Hexo的配置文件:_config.yml,更换theme为 next

    1
    theme: next
  1. 重新生成

    1
    2
    3
    4
    cd C:\blog\
    hexo clean
    hexo g
    hexo s

    重新刷新http://localhost:4000/ 网站查看结果。

升级:

NexT releases new versions every month. You can update to latest master branch by the following command:

1
2
$ cd themes/next
$ git pull

NexT主题设置

NexT主题官网: http://theme-next.iissnan.com/

NexT主题配置文件C:\blog\themes\next\_config.yml

菜单设置(左侧栏)

启用About,Tags,Categories等菜单。

1
2
3
4
5
6
menu:
home: / || fa fa-home
about: /about/ || fa fa-user
tags: /tags/ || fa fa-tags
categories: /categories/ || fa fa-th
archives: /archives/ || fa fa-archive

About页面设置

新建一个about页面:

1
$ hexo new page "about"

在blog/source下会生成一个新的文件夹about,在该文件夹下会有一个index.md文件。

头像设置

1
2
3
4
5
6
7
8
9
# Sidebar Avatar
avatar:
# Replace the default image and set the url here.
# url: /images/avatar.gif
url: /images/rock.jpg
# If true, the avatar will be dispalyed in circle.
rounded: false
# If true, the avatar will be rotated with the cursor.
rotated: false

Social设置

启用Social链接:

1
2
3
4
social:
GitHub: https://github.com/bluemirror || fab fa-github
E-Mail: mailto:rockqin@126.com || fa fa-envelope
#Weibo: https://weibo.com/yourname || fab fa-weibo

链接设置

1
2
3
links:
Bing: https://cn.bing.com/
Google: https://www.google.com

创建“标签页”和“分类页”

1
2
C:\blog>hexo n page tags
C:\blog>hexo n page categories

Tags页设置:C:\blog\source\tags\index.md

1
2
3
4
5
---
title: Tags
date: 2020-12-21 14:58:24
type: "tags"
---

Categories页设置:C:\blog\source\categories\index.md

1
2
3
4
5
---
title: Categories
date: 2020-12-21 16:35:27
type: "categories"
---

增加搜索功能

Local Search 由 flashlab 贡献,添加百度/谷歌/本地 自定义站点内容搜索。

安装 hexo-generator-searchdb,在站点的根目录下执行以下命令:

1
$ npm install hexo-generator-searchdb --save

编辑 站点配置文件,新增以下内容到任意位置:

1
2
3
4
5
search:
path: search.xml
field: post
format: html
limit: 10000

编辑 主题配置文件,启用本地搜索功能:

1
2
3
# Local search
local_search:
enable: true

不蒜子统计

编辑 主题配置文件 中的busuanzi_count的配置项。
当enable: true时,代表开启全局开关。若site_uv、site_pv、page_pv的值均为false时,不蒜子仅作记录而不会在页面上显示。

隐藏网页底部强力驱动

编辑配置文件: C:\blog\themes\next\layout_partials\footer.swig

删除或注释掉footer.powered 相关项。

1
2
3
4
5
6
7
8
9
10
11
12
13
<!--
{%- if theme.footer.powered %}

<div class="powered-by">
{%- set next_site = 'https://theme-next.org' %}
{%- if theme.scheme !== 'Gemini' %}
{%- set next_site = 'https://' + theme.scheme | lower + '.theme-next.org' %}
{%- endif %}
{{- __('footer.powered', next_url('https://hexo.io', 'Hexo', {class: 'theme-link'}) + ' & ' + next_url(next_site, 'NexT.' + theme.scheme, {class: 'theme-link'})) }}
</div>

{%- endif %}
-->

实现统计功能(字数统计和阅读时长)

A. 适用于NexT老版本,最新版无效

在站点的根目录下执行以下命令:

1
$ npm install hexo-wordcount --save

主题配置文件

1
2
3
post_wordcount:
wordcount: true
min2read: true

B. 适用于Hexo NexT v6.3.0 字数统计

参考: https://co5.me/2018/180613-wordcount.html

安装插件 hexo-symbols-xount-time

  • 卸掉你在史前教程里装的hexo-wordcount插件!

在站点的根目录下执行以下命令:

1
$ npm uninstall hexo-wordcount
  • 然后安装新插件hexo-symbols-xount-time,在站点的根目录下执行以下命令:
    1
    $ npm i hexo-symbols-count-time --save
      i 就是 install 的简写!

设置 hexo-symbols-xount-time

  • 首先在站点配置文件夹下的配置文件里,拉到最后添加如下代码:
1
2
3
4
5
symbols_count_time:
symbols: true
time: true
total_symbols: true
total_time: true
  • 然后在主题配置文件,NexT 主题其实已经自带了相关代码,搜索wordcount或者插件名可以看到如下代码:
    1
    2
    3
    4
    5
    6
    7
    8
    #Post wordcount display settings
    #Dependencies: https://github.com/theme-next/hexo-symbols-count-time
    symbols_count_time:
    separated_meta: true
    item_text_post: true
    item_text_total: false
    awl: 2
    wpm: 300
    awl(Average Word Length)的数值是设定多少字符统计为一个字(word),中文博客需要设置为 2。
    wpm(Words Per Minute)是你的阅读速度,多少字(word)统计为阅读时长一分钟。以下是官方文档里的一些阅读速度参考数据:
    ​ 慢速:200
    ​ 中速:275(默认)
    ​ 快速:350

还有给中文用户的贴心提示:因为在中文中一个词语的平均长度在 1.5 字左右,所以一般建议设置为awl=2,wpm=300。

添加备案号

打开NexT主题目录下的 \themes\next\layout\_partials\footer.swig文件,在底部加入ICP备案号并链接至”https://beian.miit.gov.cn",如下:

<a href="https://beian.miit.gov.cn/">苏ICP备xxxxxx号</a>

把备案号换成自己的备案号即可。

Nginx部署:

  1. ngnix配置文件:/usr/local/nginx/conf/nginx.conf

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    server {
    listen 80;
    server_name localhost;

    #charset koi8-r;

    #access_log logs/host.access.log main;

    location / {
    root html/public;
    index index.html index.htm;
    }
  2. HTML文件夹:/usr/local/nginx/html
    把Hexo生成的静态文件夹:public上传至: /usr/local/nginx/html

  3. Nginx启动

    1
    $ /usr/local/nginx/sbin/nginx   
  4. Nginx停止

    1
    $ killall nginx