hexo命令

1. 建站初始化cmd命令

1
2
3
4
5
6
7
8
9
10
11
#会自动从https://github.com/hexojs/hexo-starter.git拉取源文件
$ npx hexo init web

#定位根目录下的web文件夹
$ cd web

#依赖安装
$ npm install

#Hexo Deploy 部署工具安装
$ npm install hexo-deployer-git --save

2. hexo常用cmd命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#清除生成的文件
$ npx hexo clean

#生成文件
$ npx hexo generate

#运行服务
$ npx hexo server

#部署到github仓库(需配置仓库地址)
$ npx hexo deploy

#将最新的索引推送至algolia
$ npx hexo algolia

3. 博文命令

1
2
3
4
#新建md文档
$ npx hexo new '第一篇博客'
#新建页面
hexo new page "页面名称"

4. 主题更换

参考网址:参考1参考2

1
2
3
4
5
6
7
8
9
10
11
12
#卸载默认的主题
$ npm uninstall hexo-theme-landscape

#npm安装新主题
$ npm install hexo-theme-butterfly --save
#也可官网安装github版本(个人推荐,方便魔改)
$ git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly


#安装依赖插件
$ npm install hexo-renderer-pug hexo-renderer-stylus --save

5. Page配置

Front-matter用于配置,以---分割区域,注意后面有空格缩进,详情参考官网:Butterfly

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
---
【必需】
title:
date:
type:
【可选】
updated:
comments:
description:
keywords:
top_img:
mathjax:
katex:
aside:
aplayer:
highlight_shrink:
top_single_background:
---
写法 解释
title 【必需】页面标题
date 【必需】页面创建日期
type 【必需】标签—tags、分类—categories和友情链接—link三个页面需要配置
updated 【可选】页面更新日期
comments 【可选】显示页面评论模块 (默认 true)
description 【可选】页面描述
keywords 【可选】页面关键字
top_img 【可选】页面顶部图片
mathjax 【可选】显示mathjax (当设置mathjax的per_page: false时,才需要配置,默认 false)
katex 【可选】显示katex (当设置katex的per_page: false时,才需要配置,默认 false)
aside 【可选】显示侧边栏 (默认 true)
aplayer 【可选】在需要的页面加载aplayer的js和css,请参考文章下面的音乐配置
highlight_shrink 【可选】配置代码框是否展开 (true/false) (默认为设置中highlight_shrink的配置)
top_single_background 【可选】部分页面的顶部模块背景图片

6. Post配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
【必需】
title:
date:
【可选】
tags:
updated:
categories:
keywords:
description:
top_img:
comments:
cover:
toc:
toc_number:
toc_style_simple:
copyright:
copyright_author:
copyright_author_href:
copyright_url:
copyright_info:
mathjax:
katex:
aplayer:
highlight_shrink:
aside:
top_group_index:
ai:
main_color:
【置顶轮播插件】
swiper_index: 8
【文章加密插件】
tags:
- 作为日记加密
password: mikemessi
abstract: 有东西被加密了, 请输入密码查看.
message: 您好, 这里需要密码.
theme: xray
---
写法 解释
title 【必需】文章标题
date 【必需】文章创建日期
updated 【可选】文章更新日期
tags 【可选】文章标签
categories 【可选】文章分类
keywords 【可选】文章关键字
description 【可选】文章描述
top_img 【可选】文章顶部图片
cover 【可选】文章缩略图(如果没有设置top_img,文章页顶部将显示缩略图,可设为false/图片地址/留空)
comments 【可选】显示文章评论模块(默认 true)
toc 【可选】显示文章TOC(默认为设置中toc的enable配置)
toc_number 【可选】显示toc_number(默认为设置中toc的number配置)
toc_style_simple 【可选】显示 toc 简洁模式
copyright 【可选】显示文章版权模块(默认为设置中post_copyright的enable配置)
copyright_author 【可选】文章版权模块的文章作者
copyright_author_href 【可选】文章版权模块的文章作者链接
copyright_url 【可选】文章版权模块的文章连结链接
copyright_info 【可选】文章版权模块的版权声明文字
mathjax 【可选】显示mathjax(当设置 mathjax 的 per_page: false 时,才需要配置,默认 false )
katex 【可选】显示 katex (当设置 katex 的 per_page: false 时,才需要配置,默认 false )
aplayer 【可选】在需要的页面加载 aplayer 的 js 和 css,请参考文章下面的音乐 配置
highlight_shrink 【可选】配置代码框是否展开(true/false)(默认为设置中 highlight_shrink 的配置)
aside 【可选】显示侧边栏 (默认 true)
top_group_index 【可选】首页右侧卡片组配置, 数字越小越靠前
ai 【可选】文章ai摘要
main_color 【可选】文章主色,必须是16进制颜色且有6位,不可缩减,例如#ffffff 不可写成#fff
文章置顶插件
swiper_index 【可选】首页轮播图配置 index 索引,数字越小越靠前
标签
type 【必需】页面类型,必须为 tags
orderby 【可选】排序方式 :random/name/length
order 【可选】排序次序: 1, asc for ascending; -1, desc for descending

7. 常用插件

7.1. 主题渲染插件(推荐)

1
npm install hexo-renderer-pug hexo-renderer-stylus --save

7.2. Git 推送插件

1
npm install hexo-deployer-git --save

7.3. 音乐播放器插件(推荐)

1
npm install hexo-tag-aplayer --save

7.4. 哔哩哔哩追番页面生成插件

1
npm install hexo-bilibili-bangumi --save

7.5. RSS 生成插件

1
npm install hexo-generator-feed --save

7.6. algolia搜索插件(推荐)

1
npm install hexo-algoliasearch --save

7.7. 字数统计插件(推荐)

1
npm install hexo-wordcount --save

7.8. 永久链接生成插件

1
npm install hexo-abbrlink --save

7.9. 百度 Sitemap 生成插件

1
npm install hexo-generator-baidu-sitemap@0.1.4 --save

7.10. 百度主动推送插件

1
npm install hexo-baidu-url-submit --save

7.11. SiteMap 生成插件

1
npm install hexo-generator-sitemap --save

7.12. 文章双栏布局插件

1
npm i hexo-butterfly-article-double-row --save

7.13. 文章置顶插件

1
npm install hexo-generator-index-pin-top --save

7.14. 文章生成永久链接(必需)

1
npm install hexo-abbrlink --save

7.15. 文章置顶轮播插件(推荐)

1
npm install hexo-butterfly-swiper --save

7.16. 文章加密插件(推荐)

1
npm hexo-blog-encrypt --save

7.17. wow.js动画插件(推荐)

1
npm hexo-butterfly-wowjs --save

8. 图床(Github+CDN)

8.1. statically(推荐,但需FQ)

官网地址

1
2
3
4
5
# 格式 其中 :user是用户名  :repo是仓库名  :version代表版本(tag或者分支 默认为main)  :flie是文件路径
https://cdn.statically.io/gh/:user/:repo/:version/:file

# 比如我的示例仓库就是加速地址就是这个大家可以参考参考
https://cdn.statically.io/gh/DreamCollector/FigureBed/main/img/202307031714322.png

8.2. githubusercontent(无奈推荐)

1
2
3
4
5
# 格式 其中 user是用户名  repo是仓库名  version代表版本(tag或者分支 默认为main)  flie是文件路径
https://raw.githubusercontent.com/user/repo/version/file

# 比如我的示例仓库就是加速地址就是这个大家可以参考参考
https://raw.githubusercontent.com/fomalhaut1998/pic_bed/main/img/p2.webp

9. 网站Favicon

文档地址

1
2
3
4
5
接口地址:https://api.iowen.cn/favicon/{url}.png
返回格式:图片
请求方式:get
请求示例:https://api.iowen.cn/favicon/www.iowen.cn.png
参数说明:url:确保URL能够正常打开,不需要http(s):// ,且结尾必须填.png

10. npm+CDN

10.1. UNPKG

1
2
# 国内访问速度不佳
https://unpkg.com/包名@版本号/文件路径

10.2. JsDeliver

1
2
3
4
5
6
# 国内访问速度较好
https://gcore.jsdelivr.net/npm/包名@版本号/文件路径
# 国内访问速度一般
https://fastly.jsdelivr.net/npm/包名@版本号/文件路径
# 国内可能无法访问
https://cdn.jsdelivr.net/npm/包名@版本号/文件路径

10.3. 饿了么(暂不支持新包)

1
2
# 国内访问极佳,目前无任何限制,但好像不加新npm包了
https://npm.elemecdn.com/包名@版本号/文件路径

10.4. 京东

1
2
# 国内访问极佳,需申请私有包白名单
https://unpkg.shop.jd.com/包名@版本号/文件路径

10.5. 私人运营的镜像(推荐)

github文档地址

1
2
3
4
# 国内访问较好,而且有缓存
https://jsd.cdn.zzko.cn/npm/包名@版本号/文件路径
或者
https://cdn.jsdelivr.us/npm/包名@版本号/文件路径