当前位置: 首页 > 文档资料 > Hexo 中文文档 >

Front-matter

优质
小牛编辑
126浏览
2023-12-01

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

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

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

参数描述默认值
layout布局config.default_layout
title标题文章的文件名
date建立日期文件建立日期
updated更新日期文件更新日期
comments开启文章的评论功能true
tags标签(不适用于分页)
categories分类(不适用于分页)
permalink覆盖文章网址
excerptPage excerpt in plain text. Use this plugin to format the text
disableNunjucksDisable rendering of Nunjucks tag {{ }}/{% %} and tag plugins when enabled
langSet the language to override auto-detectionInherited from _config.yml

布局

The default layout is post, in accordance to 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.

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

分类和标签

只有文章支持分类和标签,您可以在 Front-matter 中设置。在其他系统中,分类和标签听起来很接近,但是在 Hexo 中两者有着明显的差别:分类具有顺序性和层次性,也就是说 Foo, Bar 不等于 Bar, Foo;而标签没有顺序和层次。

categories:
- Diary
tags:
- PS3
- Games
分类方法的分歧

如果您有过使用 WordPress 的经验,就很容易误解 Hexo 的分类方式。WordPress 支持对一篇文章设置多个分类,而且这些分类可以是同级的,也可以是父子分类。但是 Hexo 不支持指定多个同级分类。下面的指定方法:

categories:
- Diary
- Life

会使分类Life成为Diary的子分类,而不是并列分类。因此,有必要为您的文章选择尽可能准确的分类。

如果你需要为文章添加多个分类,可以尝试以下 list 中的方法。

categories:
- [Diary, PlayStation]
- [Diary, Games]
- [Life]

此时这篇文章同时包括三个分类: PlayStationGames 分别都是父分类 Diary 的子分类,同时 Life 是一个没有子分类的分类。

JSON Front-matter

除了 YAML 外,你也可以使用 JSON 来编写 Front-matter,只要将 --- 代换成 ;;; 即可。

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

最后更新:

类似资料

  • Abstract: Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python's elegant sy

  • Matterwiki 是一款简单而又美观的团队 Wiki。 Wiki 是由用户社区协作开发的网站或数据库,允许任何用户添加和编辑内容。 例如:维基百科。 随着公司的发展,很难跟踪团队中的所有知识。 很难向新团队成员传达关于公司政策的每一个细节。 事情在 Slack 通道中丢失。 保持事物在上下文中变得困难。 Wiki 可帮助跟踪所有这些信息。 每篇文章都是根据一个主题提交的,以便各部门之间保持联系

  • MatterHackers是一家在线3D打印机零售商店,也在美国加利福尼亚州开设了一家实体店,并在2013年第四季度取得了不错的业绩,并且随着3D打印市场的不断升温加剧竞争。其推出的3D打印软件MatterControl支持Mac和windows系统,不仅开源,并且易用,用户群一直在增加。 MatterControl内置通知功能,比如作品打印完成后,可发送短信和邮件给负责人,这个功能非常适合3D打

  • MatterSlice 是一个 C# 控制台程序,用来为 3D 打印生成 GCode 。这是 C++ 编写的 CuraEngine 的 C# 移植版本的增强。MatterSlice 提升了代码的可读性、稳定性和功能。

  • Mattermost 是一个 Slack 的开源替代品。Mattermost 采用 Go 语言开发,这是一个开源的团队通讯服务。为团队带来跨 PC 和移动设备的消息、文件分享,提供归档和搜索功能。 Slack 是聊天群组 + 大规模工具集成 + 文件整合 + 统一搜索。截至2014年底,Slack 已经整合了电子邮件、短信、Google Drives、Twitter、Trello、Asana、Gi

  • Matter.js 是一个基于 Web 的 2D 图形引擎。 特性: 物理属性(质量、面积、密度等) 任何凸多边形的刚体 稳定的叠加和 resting 碰撞 (broad-phase, mid-phase and narrow-phase) Restitution (elastic and inelastic collisions) Conservation of momentum Frictio