空有页面而无内容,有一点小尴尬呢~这里主要讲基础,有很多更方便更fashion的操作就先不说了,写文章要紧

创建一篇文章

1
2
3
4
5
6
# 创建一个页面
$ hexo new page <page>
# 创建一篇博客
$ hexo new post <title>
# 创建一篇草稿
$ hexo new draft <title>

默认会在source/_posts目录下创建一个xxxx.md

模板

模板在./scaffolds下,有post/draft/page三种

1
$ hexo new post "article_name"

一个模板

scaffolds/post.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
---
title: {{ title }}
date: {{ date }}
updated:
toc: true
tags:

---

简介

<!--more-->

正文

填充内容

头部

常用关键字

1
2
3
4
5
6
7
8
9
10
11
12
title: 如何在hexo博客上创建文章
date: 2019-06-05, 22:38:16
update: 2019-06-05, 22:38:16
categories:
- 基础环境配置
tags:
- hexo
- github
comments: false #是否可评论
toc: true #是否显示文章目录
description: "空有页面而无内容" #这就是保证在文章罗列的时候只显示摘要而不是所有内容

yelee主题的标签云就依赖categories和tags标签,当然后续如果想显示他们,需要在sources下创建tags和categories文件夹并编辑index.md,详见hexo分类与tags配置

当然后来食用的主题是paperbox,没有descrption选项;如果需显示摘要;加入<!--more-->那么这个标签前面的内容即为摘要

中部

这个你要会markdown就成,就正儿八经写blog

其余命令

预览草稿

如果你希望强行预览草稿,更改配置文件:

_config.yml
1
render_drafts: true

或者,如下方式启动server,本地查看:

1
$ hexo S --draft

虽然 hexo generate 不会编译 source/_drafts 目录下的文章,但 Hexo 的 Hexo server 另外提供 --draft 参数,这让我们只要搭配 hexo-browsersync plugins,就可以达到一边编辑 markdown 文章,一边使用浏览器预览的目的。

将草稿发布为正式文章

1
2
3
$ hexo P <filename>
# 或者
$ hexo publish [layout] <filename>

其中 <filename> 为不包含 md 后缀的文章名称。

发布一条龙

1
2
3
$ hexo clean
$ hexo g/generate
$ hexo d/deploy