obsidian-links

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Obsidian Wiki Links

Obsidian Wiki Links

Format, validate, and fix wiki links according to vault conventions.
按照知识库(vault)约定,格式化、验证并修复wiki链接。

When to Use This Skill

何时使用此Skill

Activate when you need to:
  • Create wiki links to other vault files
  • Add section links to specific headers
  • Format links in YAML frontmatter properties
  • Verify links point to existing files/sections
  • Find and fix broken links
  • Validate link integrity in documents
当你需要以下操作时启用此Skill:
  • 创建指向知识库中其他文件的wiki链接
  • 添加指向特定标题的章节链接
  • 格式化YAML前置属性中的链接
  • 验证链接指向的文件/章节是否存在
  • 查找并修复失效链接
  • 验证文档中的链接完整性

Core Link Formatting Rules

核心链接格式化规则

1. Complete Filename Format

1. 完整文件名格式

Always use full filename with date prefix:
markdown
✅ CORRECT: [[2025-10-31 Project Notes]]
❌ INCORRECT: [[Project Notes]] (missing date)
❌ INCORRECT: [[2025-10-31]] (missing title)
始终使用带日期前缀的完整文件名
markdown
✅ CORRECT: [[2025-10-31 Project Notes]]
❌ INCORRECT: [[Project Notes]] (缺少日期)
❌ INCORRECT: [[2025-10-31]] (缺少标题)

2. Folder Path Conventions

2. 文件夹路径约定

Include folder prefix for clarity:
markdown
✅ CORRECT: [[Journal/2025-10-31]]
✅ CORRECT: [[Articles/2025-10-31 Perennial Seller]]
✅ CORRECT: [[Roundup/2025-10-31]]
Rule: Use consistent folder prefixes for clarity and navigation.
添加文件夹前缀以提升清晰度
markdown
✅ CORRECT: [[Journal/2025-10-31]]
✅ CORRECT: [[Articles/2025-10-31 Perennial Seller]]
✅ CORRECT: [[Roundup/2025-10-31]]
规则:使用统一的文件夹前缀,以提升清晰度和导航效率。

3. Section Links

3. 章节链接

Use exact header text, character-for-character:
markdown
Source file header:
使用与标题完全一致的文本,字符完全匹配
markdown
源文件标题:

PKM System Maintenance

PKM System Maintenance

✅ CORRECT: [[Journal/2025-10-31#PKM System Maintenance]]
❌ INCORRECT: [[Journal/2025-10-31#PKM System]] (truncated) [[Journal/2025-10-31#pkm-system-maintenance]] (slug format)

**Critical**: Match characters, punctuation, spacing exactly as written.
✅ CORRECT: [[Journal/2025-10-31#PKM System Maintenance]]
❌ INCORRECT: [[Journal/2025-10-31#PKM System]] (截断文本) [[Journal/2025-10-31#pkm-system-maintenance]] (短横线格式)

**关键要求**:完全匹配字符、标点符号和空格。

4. Link to Sources, Not Indices

4. 链接至源文件而非索引

Always link to original content, not topic aggregations:
markdown
✅ CORRECT: [[Articles/2025-08-15 Skill Development]]
❌ INCORRECT: [[Topics/Career#Skill Development]]

Reason: Maintains source attribution and traceability
始终链接至原始内容,而非主题聚合页面
markdown
✅ CORRECT: [[Articles/2025-08-15 Skill Development]]
❌ INCORRECT: [[Topics/Career#Skill Development]]

原因:保留来源归因和可追溯性

5. Properties Link Format

5. 属性链接格式

Wrap links in quotes when used in YAML lists:
yaml
sources:
  - "[[Journal/2025-10-31]]"
  - "[[Articles/2025-10-31 Title]]"

links:
  - "[[Roundup/2025-10-31]]"

attendees:
  - "[[People/John]]"
在YAML列表中使用链接时,需用引号包裹
yaml
sources:
  - "[[Journal/2025-10-31]]"
  - "[[Articles/2025-10-31 Title]]"

links:
  - "[[Roundup/2025-10-31]]"

attendees:
  - "[[People/John]]"

Link Validation Principles

链接验证原则

1. Search Before Link

1. 先搜索再链接

ALWAYS verify target exists before creating link:
markdown
Process:
1. Search for target file using Glob or Grep
2. Verify file exists
3. If section link, read file and verify header exists
4. Create link with exact filename and header text

❌ NEVER:
- Guess at filenames
- Assume files exist
- Fabricate section headers
创建链接前必须验证目标是否存在
markdown
流程:
1. 使用Glob或Grep搜索目标文件
2. 验证文件是否存在
3. 如果是章节链接,读取文件并验证标题是否存在
4. 使用准确的文件名和标题文本创建链接

❌ 绝对禁止:
- 猜测文件名
- 假设文件存在
- 编造章节标题

2. Verify Section Headers

2. 验证章节标题

For section links, read source and match exactly:
markdown
Steps:
1. Read target file
2. Search for exact header text
3. Copy character-for-character (including special characters)
4. Create section link

If unsure about exact header:
✅ Link to file only: [[Journal/2025-10-31]]
❌ Don't guess: [[Journal/2025-10-31#Guessed Header]]
对于章节链接,读取源文件并完全匹配标题
markdown
步骤:
1. 读取目标文件
2. 搜索完全匹配的标题文本
3. 完全复制字符(包括特殊字符)
4. 创建章节链接

如果不确定标题的准确文本:
✅ 仅链接至文件:[[Journal/2025-10-31]]
❌ 不要猜测:[[Journal/2025-10-31#Guessed Header]]

3. File Existence Checking

3. 文件存在性检查

Use appropriate tools to verify files:
markdown
For specific file:
- Use Glob with full path pattern: "Journal/2025-10-31.md"
- Or Read the file directly

For finding files by keyword:
- Use Glob with pattern: "Articles/**/*keyword*.md"
- Check Topics directory before linking to topics
使用合适的工具验证文件是否存在
markdown
针对特定文件:
- 使用带完整路径的Glob模式:"Journal/2025-10-31.md"
- 或直接读取文件

针对关键词查找文件:
- 使用Glob模式:"Articles/**/*keyword*.md"
- 在链接至主题前,先检查Topics目录

4. Fix Broken Links Immediately

4. 立即修复失效链接

When you find broken links, fix them:
markdown
Process:
1. Identify broken link
2. Search for correct target file
3. Update link with correct path/filename (use Edit tool)
4. Verify section header if applicable
5. Report fix to user
发现失效链接后立即修复
markdown
流程:
1. 识别失效链接
2. 搜索正确的目标文件
3. 使用编辑工具更新链接,替换为正确的路径/文件名
4. 若为章节链接,验证标题是否正确
5. 向用户报告修复结果

Complete Workflow

完整工作流程

Creating New Links (Format + Validate)

创建新链接(格式化+验证)

markdown
Step 1: Determine Target
- Identify file to link to
- Note folder location
- Note complete filename

Step 2: Verify File Exists
- Use Glob: "**/{filename}.md"
- Or Read file directly
- If not found, search by keyword

Step 3: Verify Section (if needed)
- Read target file
- Search for exact header text
- Copy character-for-character
- If unsure, link to file only

Step 4: Format Link
- Use complete filename: [[YYYY-MM-DD Title]]
- Add folder prefix
- Add section if verified: [[File#Exact Header]]
- Wrap in quotes if in YAML property

Step 5: Create Link
- Link points to existing file
- Section header matches exactly (if used)
- Follows folder prefix conventions
markdown
步骤1:确定目标
- 识别要链接的文件
- 记录文件夹位置
- 记录完整文件名

步骤2:验证文件是否存在
- 使用Glob模式:"**/{filename}.md"
- 或直接读取文件
- 若未找到,通过关键词搜索

步骤3:验证章节(如有需要)
- 读取目标文件
- 搜索完全匹配的标题文本
- 完全复制字符
- 若不确定,仅链接至文件

步骤4:格式化链接
- 使用完整文件名:[[YYYY-MM-DD Title]]
- 添加文件夹前缀
- 若已验证章节,添加章节部分:[[File#Exact Header]]
- 若在YAML属性中,用引号包裹链接

步骤5:创建链接
- 链接指向已存在的文件
- 章节标题完全匹配(若使用)
- 遵循文件夹前缀约定

Finding and Fixing Broken Links

查找并修复失效链接

markdown
Step 1: Detection
- Read document content
- Extract all wiki links
- For each link, verify file exists
- For section links, verify header exists

Step 2: Search for Correct Target
- Use context to determine intent
- Search vault with Glob/Grep
- Verify file exists

Step 3: Fix Link
- Use Edit tool to update broken link
- Replace with correct path/filename
- Verify section header if applicable

Step 4: Report
- Show old link (broken)
- Show new link (fixed)
- Explain reason for fix
markdown
步骤1:检测
- 读取文档内容
- 提取所有wiki链接
- 对每个链接,验证文件是否存在
- 对章节链接,验证标题是否存在

步骤2:搜索正确目标
- 根据上下文确定意图
- 使用Glob/Grep搜索知识库
- 验证文件是否存在

步骤3:修复链接
- 使用编辑工具更新失效链接
- 替换为正确的路径/文件名
- 若为章节链接,验证标题是否正确

步骤4:报告
- 显示旧的失效链接
- 显示新的修复后链接
- 说明修复原因

Special Cases

特殊情况

Journal/Daily Files

日志/每日文件

markdown
Path: Journal/YYYY-MM-DD.md
Format: [[Journal/YYYY-MM-DD]]

Section links:
- Headers may vary by language
- ALWAYS verify exact text before linking
- If unsure, link to file only

Validation:
1. Check file: Journal/YYYY-MM-DD.md
2. Read file content
3. Search for exact header
4. Use exact match or file-only link
markdown
路径:Journal/YYYY-MM-DD.md
格式:[[Journal/YYYY-MM-DD]]

章节链接:
- 标题可能因语言而异
- 链接前必须验证准确文本
- 若不确定,仅链接至文件

验证流程:
1. 检查文件:Journal/YYYY-MM-DD.md
2. 读取文件内容
3. 搜索完全匹配的标题
4. 使用完全匹配的链接或仅文件链接

Topic Links

主题链接

markdown
CRITICAL: Search Topics directory BEFORE linking

Validation:
1. Use Glob: "Topics/**/*{keyword}*.md"
2. Find matching topic page
3. Use complete category path

Examples:
- [[Topics/Technology/PKM]]
- [[Topics/Career/Skills]]

❌ NEVER link to non-existent topic pages
markdown
关键要求:链接前先搜索Topics目录

验证流程:
1. 使用Glob模式:"Topics/**/*{keyword}*.md"
2. 找到匹配的主题页面
3. 使用完整的分类路径

示例:
- [[Topics/Technology/PKM]]
- [[Topics/Career/Skills]]

❌ 绝对禁止链接至不存在的主题页面

Person Names

人名链接

markdown
Simple name: [[John]]
With context: [[People/John]] (if folder exists)

Validation: Verify person file exists before linking
markdown
简单名称:[[John]]
带上下文:[[People/John]](若文件夹存在)

验证:链接前验证人物文件是否存在

Quality Checklist

质量检查清单

Before completing link operations:
Formatting:
  • All links use complete filenames
  • Folder prefixes follow conventions
  • Section headers match exactly (character-for-character)
  • Links in YAML properties are wrapped in quotes
  • All links point to sources, not topic indices
Validation:
  • All target files verified to exist
  • Section headers verified (not guessed)
  • Topic links point to existing topic pages
  • Broken links identified and fixed
完成链接操作前,请检查:
格式化
  • 所有链接使用完整文件名
  • 文件夹前缀遵循约定
  • 章节标题完全匹配(字符级)
  • YAML属性中的链接用引号包裹
  • 所有链接指向源文件,而非主题索引
验证
  • 所有目标文件已验证存在
  • 章节标题已验证(未猜测)
  • 主题链接指向已存在的主题页面
  • 失效链接已识别并修复