Hexo中我们常用的命令及文章配置

相关命令

1
2
3
4
5
6
hexo new "postName"		# 新建文章
hexo new page "pageName"# 新建页面
hexo generate # 生成静态页面至public目录
hexo server # 本地预览页面默认端口4000,可以通过‘ctrl+c’关闭server
hexo deploy # 将文章部署到Github
hexo version # 查看Hexo的版本
  • 常用的缩写命令:
1
2
3
4
hexo n == hexo new 
hexo g == hexo generate
hexo s == hexo server
hexo d == hexo deploy
  • 常用的组合命令:
1
2
hexo s -g		# 生成并本地预览
hexo d -g # 生成并上传
  • 写文章时需要执行的命令:
1
hexo new '文章名称'

​ 此时,Hexo会自动帮助我们在_posts文件下生成相关的md文件,使用Typora打开该文件即可开始编辑,使用该命令的好处是能够在文件夹中自动帮助我们生成文章的创建时间。当然,也可以选择把事先写好的md文件复制到_posts文件夹中。

文章相关配置

Post Front-matter

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
---
title:
date:
updated:
tags:
categories:
keywords:
description:
top_img:
comments:
cover:
toc:
toc_number:
auto_open:
copyright:
copyright_author:
copyright_author_href:
copyright_url:
copyright_info:
mathjax:
katex:
aplayer:
highlight_shrink:

---

他们分别对应:

写法 解释
title 【必须】文章标题
data 【必须】文章创建的日期
tags 文章的标签
categories 文章的分类
keywords 文章的关键字
description 文章的描述
top_img 文章顶部的图片
cover 文章的缩略图(如果没有设置top_img,文章的顶部会显示这一项设置的缩略图)
comments 文章的评论模块(默认打开)