hexo next主题 安装记录
2026-09-13 20:12:59 # 博客搭建

最近无聊有想整点东西,想这写blog,就心血来潮又搞了hexo,想着这次一定要静下心来。

安装 hexo

1
2
3
4
5
npm install hexo-cli -g --registry=https://registry.npm.taobao.org
hexo init blog
cd blog
npm install
hexo server

根据配置 修改自己的信息

官网:https://hexo.io/zh-cn/docs/configuration

安装主题 next

1
2
cd blog
git clone https://github.com/theme-next/hexo-theme-next themes/next

修改 主题配置

官网:https://theme-next.iissnan.com/getting-started.html

集成第三方插件

1.搜索

安装插件
1
npm install hexo-generator-searchdb --save --registry=https://registry.npm.taobao.org
配置博客

安装完成,编辑博客配置文件:_config.yml

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

Next 主题自带搜索设置,编辑主题配置文件:_config.yml

找到文件中 Local search 的相关配置,设为 true

1
2
3
# Local search
local_search:
enable: true

2.评论和阅读次数

注册 learncloud 进行部署

3.seo优化

参考:[https://hoxis.github.io/Hexo+Next%20SEO%E4%BC%98%E5%8C%96.html](https://hoxis.github.io/Hexo+Next SEO优化.html)

安装插件

需要安装两个插件来生成 sitemap 文件,前一个是传统的 sitemap,后一个是百度的 sitemap。

1
2
npm install hexo-generator-sitemap --save
npm install hexo-generator-baidu-sitemap --save

修改站点配置文件

将sitemap文件添加到站点配置文件_config.yml中,并修改url字段的值,其值默认为http://yoursite.com。

1
2
3
4
5
6
sitemap: 
path: sitemap.xml
baidusitemap:
path: baidusitemap.xml

url: https://libaibuaidufu.club # 这个在最开始的地方有 注意重复

rabots 协议

在站点source文件夹下新建robots.txt文件,文件内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
User-agent: *
Allow: /
Allow: /archives/
Allow: /categories/
Allow: /tags/
Allow: /resources/
Disallow: /vendors/
Disallow: /js/
Disallow: /css/
Disallow: /fonts/
Disallow: /vendors/
Disallow: /fancybox/

Sitemap: https://libaibuaidufu.club/sitemap.xml
Sitemap: https://libaibuaidufu.club/baidusitemap.xml

安装完成后执行hexo g即会在站点public目录下生成sitemap.xml和baidusitemap.xml。

Allow字段的值即为允许搜索引擎爬区的内容,可以对应到主题配置文件中的menu目录配置,如果菜单栏还有其他选项都可以按照格式自行添加。

需要将https://hoxis.github.io改成自己的域名。

github部署

github:https://hexo.io/zh-cn/docs/github-pages

一键部署:https://hexo.io/zh-cn/docs/one-command-deployment

安装插件:npm install hexo-deployer-git --save --registry=https://registry.npm.taobao.org

1
2
3
4
5
deploy:
type: git
repo: https://github.com/<username>/<project>
# example, https://github.com/hexojs/hexojs.github.io
branch: master