关于 obsidian-yaml-frontmatter
用于统一 Obsidian 笔记库中 Markdown 文件 YAML frontmatter 属性的技能,适合维护笔记属性规范的用户。它侧重属性名称、值和格式,并提供整理与校验流程。
主要功能
- 01规范属性键名与格式
- 02统一标签和日期写法
- 03格式化链接及特殊字符值
- 04检查 frontmatter 结构
适用场景
- 01为新建笔记添加 frontmatter
- 02统一现有笔记的属性格式
- 03检查标签、日期和链接写法
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ jykim/ claude-obsidian-skills --skill obsidian-yaml-frontmatter安装后在 Claude Code 中输入/obsidian-yaml-frontmatter确认已加载。
详细介绍
YAML Frontmatter 管理
统一所有知识库内容中的 YAML frontmatter 属性。
何时使用此技能
在以下情况下启用:
- 在 Markdown 文件中添加或更新 frontmatter
- 确保属性命名和格式一致
- 设置标签、日期或其他属性值的格式
- 验证 frontmatter 结构
注意:此技能用于管理 frontmatter 属性(键、值、类型、格式)。 如需管理文档结构(标题层级、章节顺序、frontmatter 位置),请使用
obsidian-markdown-structure技能。
Frontmatter 核心规则
1. 顶部只能有一个 YAML 块
结构:
---
property: value
---
## First Section Header
关键规则:
- 文件顶部只能有一个 YAML 块
- 闭合的
---后应有一个空行 - frontmatter 后、第一个标题前不能有内容
2. 标准属性名称
使用小写且一致的键:
✅ CORRECT:
title: Document Title
created: 2025-10-31
tags:
- tag1
source: https://example.com
author: Author Name
❌ INCORRECT:
Title: Document Title (capitalized)
date: 2025-10-31 (use "created" not "date")
tag: tag1 (use "tags" plural)
不得重复属性:
- 使用
created(不要同时使用date和created) - 使用
tags(不要同时使用tag和tags)
3. 标签格式
重要:YAML 中使用纯文本,不要加井号:
✅ CORRECT:
tags:
- journal
- daily
- reflection
❌ INCORRECT:
tags:
- #journal
- #daily
始终使用带短横线的列表格式:
✅ CORRECT (list format):
tags:
- tag1
- tag2
❌ INCORRECT (inline):
tags: [tag1, tag2]
4. 日期格式
统一使用 YYYY-MM-DD:
✅ CORRECT:
created: 2025-10-31
updated: 2025-11-01
❌ INCORRECT:
created: 10/31/2025
created: 2025-10-31T10:30:00
5. 链接列表
用引号括起 wiki 链接:
✅ CORRECT:
sources:
- "[[Journal/2025-10-31]]"
- "[[Articles/2025-10-31 Title]]"
links:
- "[[Roundup/2025-10-31]]"
attendees:
- "[[People/John]]"
- Jane
❌ INCORRECT:
sources:
- [[Journal/2025-10-31]] (missing quotes)
6. 为含特殊字符的值添加引号
以下内容需加引号:: # " 或看起来像数字的字符串
使用单引号包裹(适用于包含 " 的值,最简单):
✅ CORRECT:
title: 'He said, "Hello."'
note: 'It\'s called "PKM".'
使用双引号包裹并进行转义:
✅ CORRECT:
title: "He said, \"Hello.\""
source: "https://example.com"
version: "2.0"
表示字面上的双引号字符:
✅ CORRECT:
quote_char: '"'
混合引号时的首选方式:使用双引号,只转义 "(单引号无需转义):
✅ CORRECT:
note: "It's called \"PKM\"."
❌ INCORRECT:
title: AI Era: Thriving Framework (unquoted colon)
version: 2.0 (parsed as number, not string)
多行值(无需转义):
✅ CORRECT:
description: |
He said, "Hello."
New line preserved.
标准属性集
核心属性(所有内容)
---
title: Document Title
created: YYYY-MM-DD
tags:
- category
- type
---
含来源的内容
---
title: Article Title
created: YYYY-MM-DD
source: https://url or file path
author: Author Name
tags:
- clipping
- topic
---
关联内容
---
title: Document Title
created: YYYY-MM-DD
tags:
- category
sources:
- "[[Source File 1]]"
- "[[Source File 2]]"
links:
- "[[Related Topic]]"
---
事件/会议
---
title: Meeting Name
created: YYYY-MM-DD
event_date: YYYY-MM-DD
attendees:
- "[[Person 1]]"
- Person 2
sources:
- "[[Journal/YYYY-MM-DD#Section]]"
tags:
- meeting
- event
---
工作流
步骤 1:确定内容类型
- 日常内容(日记、笔记)
- 导入的内容(剪藏、文章)
- 创建的内容(分析、任务、事件)
- 主题/项目页面
步骤 2:选择属性集
- 核心属性(title、created、tags)
- 适用时添加 source/author
- 添加关联链接(sources、links、attendees)
- 添加特定内容的属性
步骤 3:设置值的格式
- 日期:YYYY-MM-DD 格式
- 标签:纯文本列表(不加 #)
- 链接:带引号的 wiki 链接
- 特殊字符:为包含
:或#的值添加引号
步骤 4:检查结构
- 顶部只有一个 YAML 块
---后有一个空行- 属性名称一致(小写)
- 没有重复属性
质量检查清单
完成 frontmatter 前,请确认:
- 顶部只有一个 YAML 块,后接一个空行
- 所有属性键均为小写且保持一致
- 标签为纯文本(不要加井号)
- 日期采用 YYYY-MM-DD 格式
- wiki 链接已用引号括起
- 特殊字符已按需加引号
- 没有重复属性(created 与 date、tags 与 tag)
评论
支持 Markdown