Foam

Link Reference Definitions

Introduction

When you use [[wiki-links]], the foam-vscode extension will automatically generate Markdown Link Reference Definitions at the bottom of the file. This is done to make the content of the file compatible with various Markdown tools (e.g. parsers, static site generators, VS code plugins etc), which don’t support [[wiki-links]].

Example

The following example:

  - [[wiki-links]]
  - [[github-pages]]

…generates the following link reference definitions to the bottom of the file:

  [wiki-links]: wiki-links "Wiki Links"
  [github-pages]: github-pages "Github Pages"

You can open the raw markdown to see them at the bottom of this file

Specification

The three components of a link reference definition are [link-label]: link-target "Link Title"

Configuration

You can choose to generate link reference definitions with or without file extensions, depending on the target. As a rule of thumb:

By default, Foam generates links without file extensions for legacy reasons, but this may change in future versions.

You can override this setting in your Foam workspace’s settings.json:

Ignoring files

Sometimes, you may want to ignore certain files or folders, so that Foam doesn’t generate link reference definitions to them.

For instance, if you’re using a local instance of Jekyll, you may find that it writes copies of each .md file into a _site directory, which may lead to Foam generating references to them instead of the original source notes.

You can ignore the _site directory by adding the following to your .vscode/settings.json:

  "files.exclude": {
    "**/_site": true
  },
  "files.watcherExclude": {
    "**/_site": true
  },

After changing the setting in your workspace, you can run the [workspace-janitor] command to convert all existing definitions.

[[Todo]] _Implement a `foam.eclude

Future improvements

See [link-reference-definition-improvements] for further discussion on current problems and potential solutions.