Skip to content

Improve Obsidian compatibility: Update YAML frontmatter tag formatting #132

@bm-claudeai

Description

@bm-claudeai

Issue: Obsidian YAML Frontmatter Tag Compatibility

Problem

Our current frontmatter logic adds tags using JSON array syntax:

tags: ["tag1", "tag2", "tag3"]

While this is valid YAML, it makes Obsidian unhappy and doesn't follow Obsidian's preferred conventions for YAML frontmatter tags.

Expected Behavior

Obsidian prefers tags in YAML frontmatter to be formatted using one of these standard YAML list formats:

Option 1: YAML List Format (Recommended)

tags:
  - tag1
  - tag2
  - tag3

Option 2: YAML Array Format (Alternative)

tags: [tag1, tag2, tag3]

Note: The unquoted format is preferred as it's cleaner and more aligned with Obsidian community conventions.

Current Impact

  • ✅ Tags work functionally in Basic Memory
  • ❌ Tags appear with JSON-style quotes in Obsidian
  • ❌ May cause visual/parsing issues in Obsidian's property editor
  • ❌ Doesn't follow Obsidian community best practices

References

Proposed Solution

Update the frontmatter generation in Basic Memory to use the YAML list format:

  1. Modify tag serialization in markdown generation
  2. Use unquoted strings for tag values (when they don't contain special characters)
  3. Use YAML list syntax with dashes instead of JSON array syntax
  4. Maintain backward compatibility for reading existing files

Implementation Areas

The changes would likely be needed in:

  • src/basic_memory/markdown/ - Markdown generation and frontmatter handling
  • src/basic_memory/services/entity_service.py - Entity creation with frontmatter
  • Tests to verify the new format works correctly

Acceptance Criteria

  • Tags are formatted using YAML list syntax (- tag) instead of JSON array syntax (["tag"])
  • Obsidian can properly parse and display the tags
  • Basic Memory can still read existing files with old format
  • All tests pass with new format
  • Documentation updated to reflect the change

Priority

Medium - Improves compatibility with a major tool in the knowledge management ecosystem, but doesn't break core functionality.

Labels

  • enhancement
  • compatibility
  • obsidian
  • yaml
  • frontmatter

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions