元数据可以应用于文章中的 YAML 扉页或全局应用于存储库的 docfx.json 文件中。 如果要编辑现有文章,可能不需要更改任何元数据。 但是,如果要添加新文章,则需要在文件的 YAML 扉页中包括某些必需元数据属性。
以下是应用在 Markdown 文章的 YAML 扉页中的元数据示例:
---
title: # the article title to show on the browser tab
description: # 115 - 145 character description to show in search results
author: {github-id} # the author's GitHub ID - will be auto-populated if set in settings.json
ms.author: {ms-alias} # the author's Microsoft alias (if applicable) - will be auto-populated if set in settings.json
ms.date: {@date} # the date - will be auto-populated when template is first applied
ms.topic: getting-started # the type of article
---
# Heading 1 <!-- the article title to show on the web page -->
必需元数据
下表显示了必需的元数据属性。 如果省略了其中任何一个元数据键,则生成期间可能会遇到验证错误。
| 字段 | 值 | 为什么? |
|---|---|---|
author |
作者的 GitHub 帐户 ID。 | 如果对内容有疑问或问题,请根据 GitHub ID 识别作者。 在某些情况下,GitHub 自动化可能会就文件的相关活动通知作者。 |
description |
内容摘要。 75-300 个字符。 | 用于站点搜索。 有时在搜索引擎结果页上用于改进 SEO。 |
ms.author |
作者的 Microsoft 别名,不带“@microsoft.com”。 如果你不是 Microsoft 员工,请查找适合在此字段中使用的 Microsoft 员工。 | 识别文章的所有者。 所有者负责决定文章的内容以及文章的报告和 BI。 |
ms.date |
采用 MM/DD/YYYY 格式的日期。 | 显示在“已发布”页面上,指示上次对文章进行了重大编辑或保证文章处于最新状态的时间。 输入日期时没有时间,解释为 0:00 且采用 UTC 时区。 向用户显示的日期将转换为其所在时区。 |
title |
页面标题。 | 这是浏览器标签页上显示的页面标题。它是 SEO 最重要的元数据。 |
属性区分大小写。 按列出的内容正确输入,在属性和值之间使用冒号和空格。 如果属性值包含冒号 (:)、哈希 (#) 或任何其他特殊字符,则必须将其括在单引号 (') 或双 (") 引号中。 例如:
---
title: 'Quickstart: How to use hashtags (#) to make a point on the internet'
---
# Heading 1 <!-- the article title to show on the web page -->