For AI agents: the complete documentation index is available at https://nhanbe.id.vn/llms.txt, the full documentation bundle is available at https://nhanbe.id.vn/llms-full.txt, and this page is available as Markdown at https://nhanbe.id.vn/others/tools/foam.md.

Setting up and using Foam as a personal knowledge management system in VS Code

Foam

Foam is an extension that turns VS Code into a personal knowledge management system based on the Zettelkasten method, similar to Obsidian but integrated directly within VS Code.


Setup

  1. Install the Foam extension from the VS Code Marketplace.
  2. Alternatively, clone the foam-template repository.
  3. Ensure your workspace includes .vscode/settings.json and .vscode/extensions.json.

Recommended complementary extensions:

  • Markdown All in One — shortcuts, Table of Contents, and preview enhancements.
  • Markdown Links — interactive clickable wikilinks.
  • Paste Image — paste images directly from clipboard.

Syntax reference:

[[note-name]]              ← Link to file note-name.md
[[note-name#heading]]      ← Link to specific section heading
[[note-name|Display Text]] ← Custom display text for link

Creating a new note: type [[new-note]] → press Ctrl+Click → Foam automatically creates the file.


Daily Notes

Execute Foam: Open Daily Note (Alt+D):

  • Automatically generates a file using the format yyyy-mm-dd.md.
  • Customize daily templates in .foam/templates/daily-note.md.

Sample template:

# ${FOAM_DATE_YEAR}-${FOAM_DATE_MONTH}-${FOAM_DATE_DATE}

## Tasks
- [ ]

## Notes

## Links

Note Templates

Define custom templates inside .foam/templates/:

---
foam_template:
  name: Meeting Note
  description: Template for meeting notes
---
# ${FOAM_TITLE}

**Date:** ${FOAM_DATE_YEAR}-${FOAM_DATE_MONTH}-${FOAM_DATE_DATE}
**Attendees:**

## Agenda

## Action Items
- [ ]

Trigger via command: Foam: Create New Note From Template


Tags

Organize content using tag annotations:

#project #aem #debug

Use command Foam: Find notes by tag to filter workspace notes.


Graph Visualization

Execute Foam: Show Graph to view your interactive knowledge graph:

  • Nodes represent notes.
  • Edges represent wikilinks connecting notes.
  • Filter node displays by folder or tag.
  • Click any node to open the corresponding note.

The Backlinks panel in the sidebar displays all notes referencing the currently active note.

Useful for:

  • Viewing contextual references surrounding a concept.
  • Identifying orphan notes (notes with zero incoming links).

Front Matter Properties

---
title: My Note
type: reference
tags: [aem, debug]
created: 2024-01-15
---

Foam indexes front matter metadata for filtering and searching.


Placeholders & Variables

Available template variables:

VariableDescription
$\{FOAM_TITLE\}File title (titlecase)
$\{FOAM_DATE_YEAR\}Current year (4 digits)
$\{FOAM_DATE_MONTH\}Current month (2 digits)
$\{FOAM_DATE_DATE\}Current day of month (2 digits)
$\{FOAM_DATE_DAY_NAME\}Day of week (e.g. Monday)

Embedded Notes

> ![[other-note]]          ← Embed entire note inline
> ![[other-note#section]]  ← Embed specific section inline

Markdown previews render embedded note contents dynamically.


workspace/
├── .foam/
│   └── templates/
│       ├── daily-note.md
│       ├── meeting.md
│       └── new-note.md
├── .vscode/
│   ├── settings.json
│   └── extensions.json
├── daily/           ← Daily journal notes
├── projects/        ← Project-specific documentation
├── references/      ← Permanent and reference notes
├── inbox/           ← Quick capture notes
└── attachments/     ← Embedded media and assets

Configuration for .vscode/settings.json:

{
  "foam.openDailyNote.directory": "daily",
  "foam.files.newNotePath": "inbox",
  "foam.edit.linkReferenceDefinitions": "withExtensions",
  "foam.graph.titleMaxLength": 24,
  "foam.dateSnippets.afterCompletion": "createNote",
  "editor.wordWrap": "on",
  "markdown.preview.breaks": true
}

Keyboard Shortcuts

ShortcutAction
Alt+DOpen Daily Note
Ctrl+Click on wikilinkNavigate to target note
Type [[Autocomplete wikilink suggestions
Ctrl+Shift+P → type "Foam"Access all Foam commands

Advanced Tips

  • Zettelkasten IDs: Prefix filenames using timestamps (e.g. 202401151030-concept-name.md) for chronological sorting.
  • MOC (Map of Content): Create index notes listing links to related notes as an alternative to folder hierarchies.
  • Git Integration: Commit notes regularly to maintain version history and backup copies.
  • Publishing with VitePress: Use wikilinks while editing, then convert to relative Markdown links during deployment workflows.
  • Orphan Notes: Run Foam: Show Graph to identify unlinked nodes for periodic review.