Provides Obsidian-style Markdown syntax support, including Wiki links, Callout annotations, embedded files, and comment syntax.
::: npm-to
npm install vitepress-plugin-obsidian:::
import { defineConfig } from 'vitepress-tuck'
import obsidian from 'vitepress-plugin-obsidian'
export default defineConfig({
plugins: [
obsidian({
// All optional, default to true
callout: true,
comment: true,
embedLink: true,
wikiLink: true,
}),
],
})Learn more about vitepress-tuck{.readmore}
import { defineConfig } from 'vitepress'
import { obsidianMarkdownPlugin } from 'vitepress-plugin-obsidian'
export default defineConfig({
markdown: {
config: (md) => {
md.use(obsidianMarkdownPlugin, {
callout: true,
comment: true,
embedLink: true,
wikiLink: true,
})
},
},
})Wiki links are Obsidian's syntax for linking to other notes. Use double brackets [[ ]] to create internal links.
[[filename]]
[[filename#heading]]
[[filename#heading#subheading]]
[[filename|alias]]
[[filename#heading|alias]]
[[https://example.com|external link]]When using Wiki links, file names are matched according to the following search rules:
Matching Priority:
- Full Path — exact match of the file path
- Fuzzy Match — match by filename at the end of the path, preferring the shortest path
Path Resolution Rules:
- Relative paths (starting with
.): resolved relative to the current file's directory - Absolute paths (not starting with
.): searched across the entire document tree, preferring the shortest match - Directory form (ending with
/): matches theindex.mdin that directory
Example:
Given the following document structure:
docs/
├── index.md
├── guide/
│ ├── index.md
│ └── markdown/
│ └── obsidian.mdIn docs/guide/markdown/obsidian.md:
| Syntax | Match Result |
|---|---|
[[obsidian]] |
matches docs/guide/markdown/obsidian.md (via filename search) |
[[./]] |
matches docs/guide/markdown/index.md (relative path) |
[[../]] |
matches docs/guide/README.md (parent directory) |
[[guide/]] |
matches docs/guide/README.md (directory form) |
External Link:
Input:
[[https://example.com|external link]]Output:
[[https://example.com|external link]]
Internal Anchor Links:
Input:
[[npm-to]] <!-- via filename search -->
[[#Wiki Links]] <!-- current page heading -->
[[file-tree#Configuration]] <!-- via filename search, link to heading -->Output:
[[npm-to]]
[[#Wiki Links]]
[[file-tree#Configuration]]
Obsidian Official - Wiki Links{.readmore}
Embed syntax allows you to insert content from other files into the current page.
![[filename]]
![[filename#heading]]
![[filename#heading#subheading]]File name search rules are the same as Wiki Links.
::: info Paths starting with / or without a ./ prefix load resources from the public directory
:::
Syntax:
![[image]]
![[image|width]]
![[image|widthxheight]]Supported formats: jpg, jpeg, png, gif, avif, webp, svg, bmp, ico, tiff, apng, jfif, pjpeg, pjp, xbm
Example:
![[tuck-logo.svg]]![[tuck-logo.svg|125]]
Note
PDF embedding requires the vitepress-plugin-pdf plugin to work properly.
Syntax:
![[document.pdf]]
![[document.pdf#page=1]] <!-- #page=1 for first page -->
![[document.pdf#page=1#height=300]] <!-- #page=page #height=height -->Supported formats: pdf
Example:
![[https://plume.pengzhanbo.cn/files/sample-1.pdf]]![[https://plume.pengzhanbo.cn/files/sample-1.pdf]]
Syntax:
![[audio file]]Supported formats: mp3, flac, wav, ogg, opus, webm, acc
Note
Video embedding requires the vitepress-plugin-video plugin to work properly.
Syntax:
![[video file]]
![[video file#height=400]] <!-- Set video height -->Supported formats: mp4, webm, mov, etc.
Use #heading to embed content fragments under specific headings:
Input:
![[my-note]]
![[my-note#heading-one]]
![[my-note#heading-one#subheading]]Obsidian Official - Embed Files{.readmore} Obsidian Official - File Formats{.readmore}
Callout is a syntax for highlighting important information, similar to VitePress's ::: note alert syntax.
> [!note]
> ContentOptional Title:
> [!tip] Custom Title
> ContentCallout supports the following types, with aliases automatically mapping to the corresponding main type:
| Type | Aliases | Description |
|---|---|---|
note |
quote, cite |
Notes, quotes |
tip |
hint, check, done, success |
Tips, hints |
info |
todo |
Info, todos |
warning |
question, help, faq |
Warnings, questions, help |
caution |
attention, failure, fail, missing, danger, error, bug |
Cautions, failures, danger |
important |
example |
Important, examples |
details |
abstract, summary, tldr |
Details, summaries |
Basic Usage:
Input:
> [!NOTE]
> This is a note callout.Output:
Note
This is a note callout.
With Title:
Input:
> [!TIP] Useful Tip
> Using `pnpm` can significantly speed up dependency installation.Output:
[!TIP] Useful Tip Using
pnpmcan significantly speed up dependency installation.
Multiple Types:
Input:
> [!success]
> Operation completed successfully!
>
> [!warning]
> This is a warning message.
>
> [!caution]
> Proceed with caution, this operation is irreversible.Output:
[!success] Operation completed successfully!
Warning
This is a warning message.
Caution
Proceed with caution, this operation is irreversible.
Details Type:
The details type renders as an HTML <details> element, supporting expand/collapse:
Input:
> [!details]
> Click to expand more content
>
> This is hidden content.Output:
[!details] Click to expand more content
This is hidden content.
Obsidian Official - Callouts{.readmore}
Content wrapped with %% is treated as a comment and will not be rendered on the page.
Inline Comments:
This is an %%inline comment%% example.Block Comments:
%%
This is a block comment.
It can span multiple lines.
%%Inline Comment:
Input:
This is an %%inline comment%% example.Output:
This is an %%inline comment%% example.
Block Comment:
Input:
Content before the comment
%%
This is a block comment.
It can span multiple lines.
%%
Content after the commentOutput:
Content before the comment
%% This is a block comment. %%
It can span multiple lines.
Obsidian Official - Comments{.readmore}
- These plugins provide compatibility support, not a full implementation of all Obsidian features
- Some Obsidian-specific features (such as graph view for internal links, backlinks, etc.) are not supported
- When embedding content, the embedded page also participates in the theme's build process
- PDF embedding requires the vitepress-plugin-pdf plugin to work properly
- Video embedding requires the vitepress-plugin-video plugin to work properly
- Embedded resources starting with
/or using./form will be loaded from thepublicdirectory