hexo博客:如何新建一个博文

新建博文

在本地根目录打开git ,使用命令新建博文

1
hexo new [layout] <title>

layout 是博文的布局,默认为 post ,可以不写。

title 是文件的名字,储存在 source/_posts 下。

注意这里的title不是文章名,具体文章中显示的文章标题可以在文章文件中修改,

其中[layout]在scaffolds中,默认情况下有三个模板post、draft、page

参数

功能

路径

post

新建文章

/source/_posts/

draft

新建草稿

/source/_drafts/

page

新建页面(标签页,分类页等)

/source/

创建文章

1
2
3
$ hexo new hexo如何新建一个博文
...
INFO Created: ~\blog\source\_posts\hexo如何新建一个博文.md

这样就创建了一篇名为”hexo如何新建一个博文”的文章了 在MarkDown编辑器上打开就可以编辑了

Front-matter 设置

Front-matter 是文件最上方以 --- 分隔的区域,用于指定个别文件的变量,举例来说:

1
2
3
4
5
---
title: hexo如何新建一个博文
date: 2022-02-06 13:10:57
tags:hexo
---

以下是预先定义的参数,可以在模板中使用这些参数值并加以利用。 官方文档

参数

描述

默认值

layout

布局

config.default_layout

title

标题

文章的文件名

date

建立日期

文件建立日期

updated

更新日期

文件更新日期

comments

开启文章的评论功能

true

tags

标签(不适用于分页)

无

categories

分类(不适用于分页)

无

permalink

覆盖文章网址

excerpt

Page excerpt in plain text. Use this plugin to format the text

disableNunjucks

Disable rendering of Nunjucks tag {{ }}/{% %} and tag plugins when enabled

lang

Set the language to override auto-detection

Inherited from _config.yml

自己设置需要的变量

1
2
3
4
---
tags: hexo
categories: 博客
---

注意 参数和值之间要用空格分隔。