Front matter allows you to keep metadata attached to an instance of a content type—i.e., embedded inside a content file—and is one of the many features that gives Hugo its strength.
当你使用hugo new posts/your_post.md
新建文章的markdown文件时,该文件已默认创建了包括标题、创建时间等信息。 这些元数据被称为Front Matter ,如果你需要了解 Hugo 预定义的 Front Matter 或更多关于 Front Matter 的内容,可以参考。 主题会提供默认的格式及内容,这些信息保存在themes/yourtheme/archetypes/posts.md
,例如Fixit主题提供模板文件:
title: "{{ replace .TranslationBaseName "-" " " | title }}"
subtitle: ""
date: {{ .Date }}
draft: true
author: ""
authorLink: ""
authorEmail: ""
description: ""
keywords: ""
license: ""
comment: false
weight: 0
tags:
- draft
categories:
- draft
hiddenFromHomePage: false
hiddenFromSearch: false
summary: ""
resources:
- name: featured-image
src: featured-image.jpg
- name: featured-image-preview
src: featured-image-preview.jpg
toc:
enable: true
math:
enable: false
lightgallery: false
seo:
images: []
repost:
enable: true
url: ""
# See details front matter: /theme-documentation-content/#front-matter
---
<!--more-->
可以将第六行author: ""
修改为author: "your name"
,这样每次新建文章,你将无需手动添加作者信息。