obsidian create inserts a leading newline, breaking frontmatter
Steps to reproduce
-
Create a new note via CLI:
obsidian create path="Test/bug_repro.md" -
Append content with frontmatter:
obsidian append path="Test/bug_repro.md" content="---\ntitle: Test\n---\n\n# Hello" -
Inspect the file with a hex dump:
xxd "<vault path>/Test/bug_repro.md" | head -3
Did you follow the troubleshooting guide? Y
Expected result
The file should start with 2d 2d 2d (the --- frontmatter delimiter at byte 0). Obsidian should parse the frontmatter normally.
Actual result
Byte 0 is 0a (newline). The frontmatter --- starts on line 2 instead of line 1, and Obsidian does not recognize it as valid frontmatter — properties are not parsed.
00000000: 0a2d 2d2d 0a74 6974 6c65 3a20 5465 7374 .---.title: Test
Environment
- Obsidian version: 1.12.7 (installer 1.12.7)
- OS: macOS 26.4 (Build 25E246), arm64
- CLI enabled via Settings → General
Additional information
obsidian create is expected to produce an empty file, but it inserts a trailing newline character. This is invisible until you append content — at which point any frontmatter is silently broken.
Workaround: Strip the leading empty line after create + append:
sed -i '' '1{/^$/d;}' "<full file path>"
Related: CLI — Ability to manipulate frontmatter for a document — native frontmatter support in the CLI would also solve this, since you wouldn’t need the create + append pattern.