docs/user/tools/cli/links.md
Show links to and from a note.
foam links (<identifier> | --path <path>) [options]
Displays the outgoing links (notes this note links to) and incoming links (notes that link to this note, also called backlinks). The command can also be invoked as foam connections.
| Option | Description |
|---|---|
--path <path> | Target note by exact file path instead of identifier |
--outgoing | Show only outgoing links |
--incoming | Show only incoming links (backlinks) |
--workspace <dir> | Workspace root (default: FOAM_WORKSPACE env var, then current directory) |
--format <fmt> | Output format: text (default) or json |
By default, both outgoing and incoming links are shown.
Show all links for a note:
foam links my-note
# Outgoing (2):
# → related-topic notes/related-topic.md
# → another-note notes/another-note.md
#
# Incoming (1):
# ← index index.md
Show only backlinks:
foam links my-note --incoming
Target by file path:
foam links --path notes/my-note.md
Get links as JSON for scripting:
foam links my-note --format json
Foam identifies notes by the shortest unique part of their filename (without extension). For example, a note at projects/alpha/notes.md might be identified as notes if that's unique, or alpha/notes if there's ambiguity. Use [[note|foam note id]] to check how a note is identified.
See also [backlinking] for the backlinks panel in VS Code.