Obsidian/Q/Can the official Obsidian CLI create wikilinks to pages and headings?
Can the official CLI for Obsidian generate wikilinks to pages and headings? card
My Answer
- CLI exists but there's no built-in way to generate wikilinks to pages and headings.
commands that could be scripted to do that
- Obsidian/CLI/file lists details for a given page.
- Obsidian/CLI/files lists all files in the vault.
- Obsidian/CLI/outline lists headings for a file. use
format=mdto get the outline.
AI Answer
- Short answer: Yes — the official Obsidian/CLI (requires Obsidian 1.12.4+ running) gets you close, but has no single "output a wikilink" command. You combine two or three of its outputs with a shell alias in your dotfiles to produce
[[Page#Heading]]strings. Official Obsidian CLI (built-in, requires running app)
- Enabled in Settings → General → Command line interface. See Obsidian/CLI for install notes.
- Useful commands for generating references:
obsidian file file="NoteName"— returns file metadata including vault-relative path, name, and extension. Pipe with--copyto clipboard.obsidian outline file="NoteName"— returns the heading tree in tree, markdown, or JSON format. Combined with--copy, you get all headings on the clipboard to construct[[NoteName#Heading]]manually.obsidian daily:path— returns today's daily note path (useful as a reference target).--copy— universal flag; adds clipboard output to any command (e.g.obsidian outline file="NoteName" --copy).
- What it cannot do natively: there is no
obsidian wikilink file="NoteName" heading="Heading"command that outputs[[NoteName#Heading]]in one step. You construct that fromfile+outlineoutput in a shell alias.
Shell alias approach (dotfiles-friendly)
Community CLI alternatives
davidpp/obsidian-cli— AI-optimized with a REST API mode; designed for agentic tools like Claude/Code.- My Notes 3 stars, typescript, funny. uses an API key to secure the localhost Obsidian server (which might be standard for obsidian)
- nightisyang/obsidian-cli — headless-first with ripgrep search and a backlink index; no running app required.
- My Note 1 star, go
Sources
- Short answer: Yes — the official Obsidian/CLI (requires Obsidian 1.12.4+ running) gets you close, but has no single "output a wikilink" command. You combine two or three of its outputs with a shell alias in your dotfiles to produce