# Markdown Features

Docusaurus uses **[Markdown](https://commonmark.org/)** as its main content authoring format.

:::callout{intent="tip" title="Learn Markdown"}
You can [learn Markdown in 10 minutes](https://commonmark.org/help/).
:::

Docusaurus uses modern tooling to help you create **interactive documentation**.

The **[MDX](https://mdxjs.com/)** compiler transforms **Markdown files to React components**, and allows you to use JSX in your Markdown content. This enables you to easily interleave React components within your content, and create delightful learning experiences.

:::callout{intent="tip" title="Use the MDX Playground"}
The **[MDX playground](https://mdxjs.com/playground/)** is your new best friend!

It is a very helpful debugging tool that shows how the MDX compiler transforms Markdown to React.

**Options**: select the right format (MDX or CommonMark) and the following plugins Docusaurus uses: `remark-gfm`, `remark-directive`, `rehype-raw`.
:::

## MDX vs. CommonMark

Docusaurus compiles both `.md` and `.mdx` files to React components using the MDX compiler, but **the syntax can be interpreted differently** depending on your settings.

The MDX compiler supports [2 formats](https://mdxjs.com/packages/mdx/#optionsformat):

- The [MDX format](https://mdxjs.com/docs/what-is-mdx/): a powerful parser allowing the usage of JSX
- The [CommonMark format](https://commonmark.org/): a standard-compliant Markdown parser that does not allow the usage of JSX

By default, **Docusaurus v3 uses the MDX format for all files** (including `.md` files) for historical reasons.

It is possible to **opt-in for CommonMark** using the [`siteConfig.markdown.format`](/guides/api-docusaurus-config-js#markdown) setting or the `mdx.format: md` front matter.

:::callout{intent="tip" title="how to use CommonMark"}
If you plan to use CommonMark, we recommend the [`siteConfig.markdown.format: 'detect'`](/guides/api-docusaurus-config-js#markdown) setting. The appropriate format will be selected automatically, based on file extensions:

- `.md` files will use the CommonMark format
- `.mdx` files will use the MDX format
:::

:::callout{intent="danger" title="Experimental CommonMark support"}
The CommonMark support is **experimental** and currently has a few [limitations](https://github.com/facebook/docusaurus/issues/9092).
:::

## Standard features

Markdown is a syntax that enables you to write formatted content in a readable syntax.

```md
### My Doc Section

Hello world message with some **bold** text, some _italic_ text, and a [link](/)

![img alt](/img/docusaurus.png)
```

```mdx-code-block
<BrowserWindow>

<h3>My Doc Section</h3>

Hello world message with some **bold** text, some _italic_ text and a [link](/)

![img alt](/img/docusaurus.png)

</BrowserWindow>
```

:::accordion{title="Markdown is declarative"}
Some may assume a 1-1 correlation between Markdown and HTML, e.g., `![Preview](/img/docusaurus.png)` will always become `<img src="/img/docusaurus.png" alt="Preview" />`, as-is. However, _that is not the case_.

The Markdown syntax `![message](url)` only declaratively tells Docusaurus that an image needs to be inserted here, but we may do other things like transforming a [file path to URL path](/guides/guides-markdown-features-markdown-features-assets#images), so the generated markup may differ from the output of other Markdown renderers, or a naïve hand-transcription to the equivalent JSX/HTML code.

In general, you should only assume the _semantics_ of the markup (` ``` ` fences become [code blocks](/guides/guides-markdown-features-markdown-features-code-blocks); `>` becomes [quotes](#quotes), etc.), but not the actual compiled output.
:::

## Front matter

Front matter is used to add metadata to your Markdown file. All content plugins have their own front matter schema, and use the front matter to enrich the default metadata inferred from the content or other configuration.

Front matter is provided at the very top of the file, enclosed by three dashes `---`. The content is parsed as [YAML](https://yaml.org/spec/1.2.2/).

```md
---
title: My Doc Title
more_data:
  - Can be provided
  - as: objects
    or: arrays
---
```

:::callout{intent="info"}
The API documentation of each official plugin lists the supported attributes:

- [Docs front matter](/guides/api-plugins-plugin-content-docs#markdown-front-matter)
- [Blog front matter](/guides/api-plugins-plugin-content-blog#markdown-front-matter)
- [Pages front matter](/guides/api-plugins-plugin-content-pages#markdown-front-matter)
:::

:::callout{intent="tip" title="enhance your front matter"}
Use the [Markdown config `parseFrontMatter` function](/guides/api-docusaurus-config-js#markdown) to provide your own front matter parser, or to enhance the default parser.

It is possible to reuse the default parser to wrap it with your own custom proprietary logic. This makes it possible to implement convenient front matter transformations, shortcuts, or to integrate with external systems using front matter that Docusaurus plugins do not support.

```js title="docusaurus.config.js" {3-24}
export default {
  markdown: {
    parseFrontMatter: async (params) => {
      // Reuse the default parser
      const result = await params.defaultParseFrontMatter(params);

      // Process front matter description placeholders
      result.frontMatter.description =
        result.frontMatter.description?.replaceAll('{{MY_VAR}}', 'MY_VALUE');

      // Create your own front matter shortcut
      if (result.frontMatter.i_do_not_want_docs_pagination) {
        result.frontMatter.pagination_prev = null;
        result.frontMatter.pagination_next = null;
      }

      // Rename an unsupported front matter coming from another system
      if (result.frontMatter.cms_seo_summary) {
        result.frontMatter.description = result.frontMatter.cms_seo_summary;
        delete result.frontMatter.cms_seo_summary;
      }

      return result;
    },
  },
};
```
:::

## Quotes

Markdown quotes are beautifully styled:

```md
> Easy to maintain open source documentation websites.
>
> — Docusaurus
```

> Easy to maintain open source documentation websites.
>
> — Docusaurus

## Details

Markdown can embed HTML elements, and [`details`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details) HTML elements are beautifully styled:

````md
### Details element example

<details>
  <summary>Toggle me!</summary>

  This is the detailed content

  ```js
  console.log("Markdown features including the code block are available");
  ```

  You can use Markdown here including **bold** and _italic_ text, and [inline link](https://docusaurus.io)
  <details>
    <summary>Nested toggle! Some surprise inside...</summary>

    😲😲😲😲😲
  </details>
</details>
````

````mdx-code-block
<BrowserWindow>

<h3>Details element example</h3>

<details>
  <summary>Toggle me!</summary>

  This is the detailed content

  ```js
  console.log("Markdown features including the code block are available");
  ```

  You can use Markdown here including **bold** and _italic_ text, and [inline link](https://docusaurus.io)
  <details>
    <summary>Nested toggle! Some surprise inside...</summary>

    😲😲😲😲😲
  </details>
</details>

</BrowserWindow>
````

:::callout{intent="info"}
You may want to keep your `<summary>` on a single line. Keep in mind that [MDX creates extra HTML `<p>` paragraphs for line breaks.](https://mdxjs.com/migrating/v2/#jsx). When in doubt, use the [MDX playground](https://mdxjs.com/playground/) to troubleshoot `<details>` rendering problems.
:::

## Tables

Markdown tables are supported via **[GitHub Flavored Markdown (GFM)](https://github.github.com/gfm/#tables-extension-)**. They are an excellent way to display structured data in your documentation.

```md
| Feature    | Support | Description                       |
| :--------- | :------ | :-------------------------------- |
| GFM Tables | ✅ Yes  | Standard Markdown table syntax    |
| Alignment  | ✅ Yes  | Left, center, and right alignment |
```

```mdx-code-block
<BrowserWindow>

| Feature    | Support | Description                       |
| :--------- | :------ | :-------------------------------- |
| GFM Tables | ✅ Yes  | Standard Markdown table syntax    |
| Alignment  | ✅ Yes  | Left, center, and right alignment |

</BrowserWindow>
```

## Related pages

- [Diagrams](./guides-markdown-features-markdown-features-diagrams.md)
- [Admonitions](./guides-markdown-features-markdown-features-admonitions.md)
- [Assets](./guides-markdown-features-markdown-features-assets.md)
- [Code blocks](./guides-markdown-features-markdown-features-code-blocks.md)
- [Head metadata](./guides-markdown-features-markdown-features-head-metadata.md)
- [Markdown links](./guides-markdown-features-markdown-features-links.md)
- [Math Equations](./guides-markdown-features-markdown-features-math-equations.md)
- [MDX Plugins](./guides-markdown-features-markdown-features-plugins.md)
- [MDX and React](./guides-markdown-features-markdown-features-react.md)
- [Tabs](./guides-markdown-features-markdown-features-tabs.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
