# Markdown

Markdown pages with Vue components.

Each page is a Markdown file in `content/`, with [GitHub Flavored Markdown](https://github.github.com/gfm/) like tables, task lists and footnotes. Pages are also Vue templates, so components work anywhere in them.

## Frontmatter [#frontmatter]

Frontmatter is the YAML block at the top of a page. Only `title` is required:

```yaml title="content/install.md"
---
title: Installation # The page heading, and its name in the sidebar
description: Install Acme in your project. # Shown under the heading and in search results
icon: Rocket # A Lucide icon beside the name, with `lucideIconsPlugin()`
full: true # Use the full width, without the table of contents
draft: true # Show the page in `vuesho dev` only
date: 2026-11-25 # When the page was written, for feeds
layout: home # The layout to use, from the theme
ogImage: # The texts of the Open Graph image, with `ogImagePlugin()`
  title: Install Acme in a Minute
---
```

The title renders as the page heading, so start the body at `##`. To add custom fields, define a [frontmatter schema](/markdown/collections#frontmatter-schema).

### Computed Frontmatter [#computed-frontmatter]

To compute frontmatter when the site builds, export `frontmatter` from a `<script>` block. Its fields override the YAML:

```md title="content/requirements.md"
---
title: Requirements
---

<script>
import { version } from "vue/package.json";

export const frontmatter = { description: `Built with Vue ${version}.` };
</script>
```

## Headings [#headings]

Vuesho generates each heading's ID from its text. Add a tag at the end of a heading to set its ID, or to change how the table of contents shows it:

```md
## Installation

<!-- The ID is "setup" instead of "installation". -->

## Installation [#setup]

<!-- Hidden from the table of contents. -->

## Changelog [!toc]

<!-- Only in the table of contents, for a section that a component renders. -->

## Options [toc]
```

## Links [#links]

Link to another page by its file path, relative to the current page. Vuesho resolves the link to that page's URL, with the [base path](/deploying#base-path):

```md title="content/guide/index.md"
See [the requirements](./install.md#requirements).

<!-- A URL works too. -->

See [the API](/reference/api).
```

A link from the root, like `/reference/api`, is a URL of the site. A URL ending in `.md` is a page's [Markdown version](/ai), so link to a page by its URL without the extension, or by its relative path.

### Link Validation [#link-validation]

`vuesho build` fails when a link points to a page or a heading that doesn't exist. Configure the check in the recommended preset:

```ts title="vuesho.config.ts"
createSite(docs.toSource()).plugins(
  recommendedPreset({
    linkValidation: {
      // Skip some links
      ignore: (link) => link.href.startsWith("/api/"),
      // Check external links too
      external: async (url) => (await fetch(url, { method: "HEAD" })).ok,
      // Handle dead links yourself, instead of failing the build
      report: (links) => console.warn(links),
    },
  }),
);
```

## Images [#images]

A relative path points to an image next to the page, which is bundled with it. An absolute path points to a file in `public/`:

```md
![The editor](./editor.png)

![The logo](/logo.png)
```

[Images](/markdown/images) covers their sizes, placeholders and optimization.

## Code Blocks [#code-blocks]

Add a title and line numbers after the language, and highlight a line with a comment:

````md tab="Input"
```ts title="src/greet.ts" lineNumbers
export function greet(name: string) {
  return `Hello, ${name}!`; // [\!code highlight]
}
```
````

```ts title="src/greet.ts" lineNumbers tab="Output"
export function greet(name: string) {
  return `Hello, ${name}!`; // [!code highlight]
}
```

`lineNumbers=10` starts the numbers at 10, and `noCopy` hides the copy button. [Code Blocks](/markdown/code-blocks) covers code themes and other highlighters.

### Line Notations [#line-notations]

A `[!code …]` comment applies to its own line. Add `:3` to apply it to three lines, like `[!code highlight:3]`:

````md tab="Input"
```ts
// [\!code word:name]
const name = "Acme"; // [\!code highlight]
console.log("hello"); // [\!code --]
console.log(`Hello, ${name}!`); // [\!code ++]
greet(name); // [\!code focus]
```
````

```ts tab="Output"
// [!code word:name]
const name = "Acme"; // [!code highlight]
console.log("hello"); // [!code --]
console.log(`Hello, ${name}!`); // [!code ++]
greet(name); // [!code focus]
```

### Inline Code [#inline-code]

To highlight inline code, add `{:lang}` at its end: `` `console.log("hi"){:js}` `` renders as `console.log("hi")`.

### Code Tabs [#code-tabs]

Consecutive code blocks with a `tab` attribute become tabs. Tabs with the same `tab-group` stay in sync, even across pages:

````md
```ts tab="TypeScript" tab-group="language"
const count: number = 1;
```

```js tab="JavaScript"
const count = 1;
```
````

```ts tab="TypeScript" tab-group="language"
const count: number = 1;
```

```js tab="JavaScript"
const count = 1;
```

An `npm` code block becomes one tab per package manager:

````md
```npm
npm i acme
```
````

```npm
npm i acme
```

## Components [#components]

The [built-in components](/markdown/components), and those in `src/components/content/`, work in every page without an import. As in a Vue template, an attribute is a string, and a `:` prefix makes it an expression. Markdown works inside a component:

```md
<Callout type="warn" title="Careful">
  This can't be **undone**.
</Callout>

<Tabs :items="['npm', 'pnpm']">
  <Tab value="npm">Run `npm i acme`.</Tab>
  <Tab value="pnpm">Run `pnpm add acme`.</Tab>
</Tabs>
```

<Callout type="warn" title="Careful">
This can't be **undone**.
</Callout>

<Tabs :items='["npm","pnpm"]'>
<Tab value="npm">Run `npm i acme`.</Tab>

<Tab value="pnpm">Run `pnpm add acme`.</Tab>
</Tabs>

## Vue in Markdown [#vue-in-markdown]

A page is a Vue component, so it can use expressions, directives, `<script setup>` and `<style>`:

```md title="content/counter.md"
<button class="counter" @click="count++">Clicked {{ count }} times</button>

<script setup>
import { ref } from "vue";

const count = ref(0);
</script>

<style scoped>
.counter {
  padding: 4px 12px;
  border: 1px solid var(--color-fd-border);
  border-radius: 8px;
}
</style>
```

<button>Clicked 0 times</button>

<Callout title="Server Rendering">
A page renders on the server first. Use browser APIs like `window` only in `onMounted()` or in
event handlers, as in [Vue's SSR guide](https://vuejs.org/guide/scaling-up/ssr.html#writing-ssr-friendly-code).
</Callout>

### Escaping [#escaping]

Vue only parses tags and `{{ }}`, so other braces render as text. To show a tag or `{{` as text, escape it with a backslash:

```md
Braces like {a, b} are text, and so is a < b.

\{{ name }} and Array\<string> are text too.
```

### Vapor Mode [#vapor-mode]

On Vue 3.6, opt a page into Vapor mode with `<script setup vapor>`.

## Includes [#includes]

`<include>` inserts a `.md` file into the page, so its headings appear in the table of contents and in search. Start the name of an included file with `_`, so it isn't a page of its own:

```md
<!-- A whole file -->

<include>./_install.md</include>

<!-- A heading with its content, or a <section id="options"> -->

<include>./api.md#options</include>

<!-- The lines between `#region options` and `#endregion options` -->

<include>../src/config.ts#options</include>

<!-- Lines 3 to 10, or from line 3 with {3,} -->

<include>../src/config.ts{3,10}</include>

<!-- A file from the project root, with a title -->

<include cwd meta='title="vite.config.ts"'>vite.config.ts</include>
```

Any other file, `.mdx` included, renders as a code block, highlighted by its file extension unless `lang` sets another language. After a section or a region, a range counts from the first line of that section or region, like `<include>../src/config.ts#options{2,4}</include>`.

### Props [#props]

An included file declares props with `defineProps()`, and an include passes them as attributes, with `:` for an expression:

```md tab="content/_greeting.md"
<script setup lang="ts">
defineProps<{ framework: string }>();
</script>

## Deploy on {{ framework }}

Hello from **{{ framework }}**.
```

```md tab="content/index.md"
<include framework="Vue">./_greeting.md</include>
```

- The included file reads only its props, so a page with [path params](/routing#path-params) passes them on, like `:framework="framework"`.
- With [type checking](/markdown/type-checking), a missing prop or a value of the wrong type is a type error.

### Scripts and Styles [#scripts-and-styles]

Each include renders the file as a component, so its `<script setup>`, `<script>` and `<style scoped>` work as in a `.vue` file. Each include has its own state, and imports resolve from the included file:

```md title="content/_counter.md"
<script setup>
import { ref } from "vue";

const count = ref(0);
</script>

<button class="counter" @click="count++">Clicked {{ count }} times</button>

<style scoped>
.counter {
  padding: 4px 12px;
}
</style>
```

## markdown-it Plugins [#markdown-it-plugins]

Vuesho parses Markdown with [markdown-it](https://github.com/markdown-it/markdown-it). Add its plugins to `markdown.markdownItPlugins`, like `@mdit/plugin-emoji` for emoji shortcodes:

```npm
npm i @mdit/plugin-emoji
```

```ts title="vuesho.config.ts"
import { fullEmoji } from "@mdit/plugin-emoji"; // [!code ++]

createSite(docs.toSource()).config({
  markdown: { markdownItPlugins: [fullEmoji] }, // [!code ++]
});
```

For math, see [Math](/markdown/math). To add syntax from a Vuesho plugin, see [Markdown Extensions](/markdown-extensions).
