hexo基础使用
创建新的文章,默认是post
| 1
 | hexo new [layout] <title>
 | 
常用参数
| 参数 | 描述 | 默认值 | 
|---|
| layout | 布局 | config.default_layout | 
| title | 标题 | 文章的文件名 | 
| date | 建立日期 | 文件建立日期 | 
| updated | 更新日期 | 文件更新日期 | 
| comments | 开启文章的评论功能 | true | 
| tags | 标签(不适用于分页) |  | 
| categories | 分类(不适用于分页) |  | 
| permalink | 覆盖文章网址 |  | 
分类标签写法:
| 12
 3
 4
 5
 6
 
 | tags:- PS3
 - Games
 categories:
 - Diary
 - Life
 
 | 
多分类写法
| 12
 3
 4
 
 | categories:- [Diary, PlayStation]
 - [Diary, Games]
 - [Life]
 
 | 
此时这篇文章同时包括三个分类: PlayStation 和 Games 分别都是父分类 Diary 的子分类,同时 Life 是一个没有子分类的分类。
引用图片
| 12
 3
 
 | or
 <img src="/2020/01/02/foo/image.jpg">
 
 | 
部署Github
私有 Repository
下面的指示基于 一键部署 编写。
- 安装 hexo-deployer-git.
| 1
 | cnmp install hexo-deployer-git
 | 
- 在 _config.yml(如果有已存在的请删除)添加如下配置:
| 12
 3
 4
 5
 
 | deploy:type: git
 repo: https://github.com/<username>/<project>
 # example, https://github.com/hexojs/hexojs.github.io
 branch: gh-pages
 
 | 
- 运行 hexo clean && hexo deploy。
- 查看 username.github.io 上的网页是否部署成功。
配置永久链接
| 变量 | 描述 | 
|---|
| :year | 文章的发表年份(4 位数) | 
| :month | 文章的发表月份(2 位数) | 
| :i_month | 文章的发表月份(去掉开头的零) | 
| :day | 文章的发表日期 (2 位数) | 
| :i_day | 文章的发表日期(去掉开头的零) | 
| :hour | 文章发表时的小时 (2 位数) | 
| :minute | 文章发表时的分钟 (2 位数) | 
| :second | 文章发表时的秒钟 (2 位数) | 
| :title | 文件名称 (relative to “source/_posts/“ folder) | 
| :name | 文件名称 | 
| :post_title | 文章标题 | 
| :id | 文章 ID (not persistent across cache reset) | 
| :category | 分类。如果文章没有分类,则是 default_category配置信息。 | 
| :hash | SHA1 hash of filename (same as :title) and date (12-hexadecimal) | 
您可在 permalink_defaults 参数下调整永久链接中各变量的默认值:
| 12
 
 | permalink_defaults:lang: en
 
 | 
示例
| 12
 3
 4
 5
 
 | source/_posts/hello-world.mdtitle: Hello Worlddate: 2013-07-14 17:01:34
 categories:
 - foo
 - bar
 
 | 
| 参数 | 结果 | 
|---|
| :year/:month/:day/:title/ | 2013/07/14/hello-world/ | 
| :year-:month-:day-:title.html | 2013-07-14-hello-world.html | 
| :category/:title/ | foo/bar/hello-world/ | 
| :title-:hash/ | hello-world-a2c8ac003b43/ | 
| 12
 3
 4
 5
 
 | source/_posts/lorem/hello-world.mdtitle: Hello Worlddate: 2013-07-14 17:01:34
 categories:
 - foo
 - bar
 
 | 
| 参数 | 结果 | 
|---|
| :year/:month/:day/:title/ | 2013/07/14/lorem/hello-world/ | 
| :year/:month/:day/:name/ | 2013/07/14/hello-world/ | 
多语种支持
若要建立一个多语种的网站,您可修改 new_post_name 和 permalink 参数,如下:
| 12
 
 | new_post_name: :lang/:title.mdpermalink: :lang/:title/
 
 | 
当您建立新文章时,文章会被储存到:
| 12
 
 | $ hexo new "Hello World" --lang tw# => source/_posts/tw/Hello-World.md
 
 | 
而网址会是:
| 1
 | http://localhost:4000/tw/hello-world/
 | 
目录介绍
| 12
 3
 4
 5
 6
 
 | .├── _config.yml
 ├── languages
 ├── layout
 ├── scripts
 └── source
 
 | 
开启代码高亮
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 
 | highlight:
 enable: true
 auto_detect: false
 line_number: true
 line_threshold: 0
 tab_replace: '  '
 exclude_languages:
 - example
 wrap: true
 hljs: false
 prismjs:
 enable: false
 
 |