Hexo博客更换主题

在文章Hexo搭建个人博客中我们介绍了如何利用Hexo搭建个人博客,刚搭建默认的主题是landscape,我们也可以更换自己喜欢的主题,这里以更换NexT主题为例

NexT主题GitHub首页:https://github.com/theme-next/hexo-theme-next

安装主题

首先进入博客项目根目录

1
2
3
d:\>cd hexo/blog

d:\hexo\blog>

Click and drag to move

然后安装NexT主题

命令:git clone https://github.com/theme-next/hexo-theme-next themes/next

1
2
3
4
5
6
7
8
D:\hexo\blog>git clone https://github.com/theme-next/hexo-theme-next themes/next
Cloning into 'themes/next'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 7195 (delta 0), reused 1 (delta 0), pack-reused 7187
Receiving objects: 100% (7195/7195), 5.57 MiB | 652.00 KiB/s, done.
Resolving deltas: 100% (4640/4640), done.

Click and drag to move

主题下载成功后存放在如下目录:博客根目录/themes目录下

配置主题

在项目根目录下打开_config.yml文件,找到theme属性,改成

1
theme: next

Click and drag to move

重启服务

重启服务后即可生效

1
2
3
4
5
6
7
8
9
10
11
12
13
D:\hexo\blog>hexo g
INFO Start processing
INFO Files loaded in 883 ms
INFO Generated: archives/2019/index.html
INFO Generated: 2019/06/16/hello-world/index.html
INFO Generated: archives/index.html
INFO Generated: archives/2019/06/index.html
INFO Generated: index.html
INFO 5 files generated in 731 ms

D:\hexo\blog>hexo s
INFO Start processing
INFO Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.

Click and drag to move

更新NexT

首先进入NexT主题所在路径

1
D:\>cd D:/hexo/blog/themes/next

Click and drag to move

然后执行命令:git pull

1
2
D:\hexo\blog\themes\next>git pull
Already up to date.

Click and drag to move