前言

Front-matter 是文件开头的 YAML 或 JSON 块,用于配置你的作品的设置。Front-matter 以 YAML 编写时以三个破折号结束,以 JSON 编写时以三个分号结束。

¥Front-matter is a block of YAML or JSON at the beginning of the file that is used to configure settings for your writings. Front-matter is terminated by three dashes when written in YAML or three semicolons when written in JSON.

YAML

---
title: Hello World
date: 2013/7/13 20:46:25
---

JSON

"title": "Hello World",
"date": "2013/7/13 20:46:25"
;;;

设置及其默认值

¥Settings & Their Default Values

设置 描述 默认
layout 布局 config.default_layout
title 标题 文件名(仅限帖子)
date 发布日期 文件创建日期
updated 更新日期 文件更新日期
comments 为帖子启用评论功能 true
tags 标签(不适用于页面)
categories 类别(不适用于页面)
permalink 覆盖帖子的默认永久链接。永久链接应以 /.html 结尾 null
excerpt 纯文本形式的页面摘录。使用 此插件 格式化文本
disableNunjucks 启用时禁用 Nunjucks 标签 {{ }}/{% %}标签插件 的渲染 false
lang 设置语言以覆盖 auto-detection 继承自 _config.yml
published 是否应发布帖子 对于 _posts 下的帖子,它是 true,对于 _draft 下的帖子,它是 false

布局

¥Layout

默认布局为 post,与 _config.ymldefault_layout 设置的值一致。当文章中的布局被禁用(layout: false)时,它将不会被主题处理。但是,它仍将由任何可用的渲染器渲染:如果文章是用 Markdown 编写的,并且安装了 Markdown 渲染器(如默认的 hexo-renderer-marked),它将被渲染为 HTML。

¥The default layout is post, in accordance with the value of default_layout setting in _config.yml. When the layout is disabled (layout: false) in an article, it will not be processed with a theme. However, it will still be rendered by any available renderer: if an article is written in Markdown and a Markdown renderer (like the default hexo-renderer-marked) is installed, it will be rendered to HTML.

无论布局如何,标签插件 始终会被处理,除非 disableNunjucks 设置或 renderer 禁用。

¥Tag plugins are always processed regardless of layout, unless disabled by the disableNunjucks setting or renderer.

类别和标签

¥Categories & Tags

仅帖子支持使用分类和标签。类别按顺序应用于帖子,从而产生分类和子分类的层次结构。标签都定义在同一层次结构级别上,因此它们出现的顺序并不重要。

¥Only posts support the use of categories and tags. Categories apply to posts in order, resulting in a hierarchy of classifications and sub-classifications. Tags are all defined on the same hierarchical level so the order in which they appear is not important.

示例

¥Example

categories:
- Sports
- Baseball
tags:
- Injury
- Fight
- Shocking

如果你想要应用多个类别层次结构,请使用名称列表而不是单个名称。如果 Hexo 在帖子上看到任何以这种方式定义的类别,它会将该帖子的每个类别视为其自己的独立层次结构。

¥If you want to apply multiple category hierarchies, use a list of names instead of a single name. If Hexo sees any categories defined this way on a post, it will treat each category for that post as its own independent hierarchy.

示例

¥Example

categories:
- [Sports, Baseball]
- [MLB, American League, Boston Red Sox]
- [MLB, American League, New York Yankees]
- Rivalries