Authoring Content in Markdown
Starlight supports the full range of Markdown syntax in .md files as well as frontmatter YAML to define metadata such as a title and description.
Please be sure to check the MDX docs or Markdoc docs if using those file formats, as Markdown support and usage can differ.
Frontmatter
Section titled âFrontmatterâYou can customize individual pages in Starlight by setting values in their frontmatter.
Frontmatter is set at the top of your files between --- separators:
---
title: My page title
---
Page content follows the second `---`.Every page must include at least a title.
See the frontmatter reference for all available fields and how to add custom fields.
Inline styles
Section titled âInline stylesâText can be bold, italic, or strikethrough.
Text can be **bold**, _italic_, or ~~strikethrough~~.You can link to another page.
You can [link to another page](/getting-started/).You can highlight inline code with backticks.
You can highlight `inline code` with backticks.Images in Starlight use Astroâs built-in optimized asset support.
Markdown and MDX support the Markdown syntax for displaying images that includes alt-text for screen readers and assistive technology.

Relative image paths are also supported for images stored locally in your project.
// src/content/docs/page-1.md
Headings
Section titled âHeadingsâYou can structure content using a heading. Headings in Markdown are indicated by a number of # at the start of the line.
How to structure page content in Starlight
Section titled âHow to structure page content in StarlightâStarlight is configured to automatically use your page title as a top-level heading and will include an "Overview" heading at top of each page's table of contents. We recommend starting each page with regular paragraph text content and using on-page headings from <h2> and down:
---
title: Markdown Guide
description: How to use Markdown in Starlight
---
This page describes how to use Markdown in Starlight.
## Inline Styles
## HeadingsAutomatic heading anchor links
Section titled âAutomatic heading anchor linksâUsing headings in Markdown will automatically give you anchor links so you can link directly to certain sections of your page:
---
title: My page of content
description: How to use Starlight's built-in anchor links
---
## Introduction
I can link to [my conclusion](#conclusion) lower on the same page.
## Conclusion
`https://my-site.com/page1/#introduction` navigates directly to my Introduction.Level 2 (<h2>) and Level 3 (<h3>) headings will automatically appear in the page table of contents.
Learn more about how Astro processes heading ids in the Astro Documentation
Asides (also known as âadmonitionsâ or âcalloutsâ) are useful for displaying secondary information alongside a pageâs main content.
Starlight provides a custom Markdown syntax for rendering asides. Aside blocks are indicated using a pair of triple colons ::: to wrap your content, and can be of type note, tip, caution or danger.
You can nest any other Markdown content types inside an aside, but asides are best suited to short and concise chunks of content.
Note aside
Section titled âNote asideâ:::note
Starlight is a documentation website toolkit built with [Astro](https://astro.build/). You can get started with this command:
```sh
npm create astro@latest -- --template starlight
```
:::Custom aside titles
Section titled âCustom aside titlesâYou can specify a custom title for the aside in square brackets following the aside type, e.g. :::tip[Did you know?].
:::tip[Did you know?]
Astro helps you build faster websites with [âIslands Architectureâ](https://docs.astro.build/en/concepts/islands/).
:::Custom aside icons
Section titled âCustom aside iconsâYou can specify a custom icon for the aside in curly brackets following the aside type or custom title, e.g. :::tip{icon="heart"} or :::tip[Did you know?]{icon="heart"} respectively.
The icon name must be set to the name of one of Starlightâs built-in icons.
:::tip{icon="heart"}
Astro helps you build faster websites with [âIslands Architectureâ](https://docs.astro.build/en/concepts/islands/).
:::More aside types
Section titled âMore aside typesâCaution and danger asides are helpful for drawing a userâs attention to details that may trip them up. If you find yourself using these a lot, it may also be a sign that the thing you are documenting could benefit from being redesigned.
:::caution
If you are not sure you want an awesome docs site, think twice before using [Starlight](/).
:::
:::danger
Your users may be more productive and find your product easier to use thanks to helpful Starlight features.
- Clear navigation
- User-configurable colour theme
- [i18n support](/guides/i18n/)
:::Blockquotes
Section titled âBlockquotesâThis is a blockquote, which is commonly used when quoting another person or document.
Blockquotes are indicated by a
>at the start of each line.
> This is a blockquote, which is commonly used when quoting another person or document.
>
> Blockquotes are indicated by a `>` at the start of each line.Code blocks
Section titled âCode blocksâA code block is indicated by a block with three backticks ``` at the start and end. You can indicate the programming language being used after the opening backticks.
// Javascript code with syntax highlighting.
var fun = function lang(l) {
dateformat.i18n = require('./lang/' + l);
return true;
};```js
// Javascript code with syntax highlighting.
var fun = function lang(l) {
dateformat.i18n = require('./lang/' + l);
return true;
};
```Expressive Code features
Section titled âExpressive Code featuresâStarlight uses Expressive Code to extend formatting possibilities for code blocks.
Expressive Codeâs text markers and window frames plugins are enabled by default.
Code block rendering can be configured using Starlightâs expressiveCode configuration option.
Text markers
Section titled âText markersâYou can highlight specific lines or parts of your code blocks using Expressive Code text markers on the opening line of your code block.
Use curly braces ({ }) to highlight entire lines, and quotation marks to highlight strings of text.
There are three highlighting styles: neutral for calling attention to code, green for indicating inserted code, and red for indicating deleted code.
Both text and entire lines can be marked using the default marker, or in combination with ins= and del= to produce the desired highlighting.
Expressive Code provides several options for customizing the visual appearance of your code samples. Many of these can be combined, for highly illustrative code samples. Please explore the Expressive Code documentation for the extensive options available. Some of the most common examples are shown below:
-
Mark entire lines & line ranges using the
{ }marker:JavaScript function demo() { // This line (#2) and the next one are highlighted return 'This is line #3 of this snippet';}Markdown ```js {2-3} function demo() { // This line (#2) and the next one are highlighted return 'This is line #3 of this snippet'; } ```markdoc ```js {% meta="{2-3}" %} function demo() { // This line (#2) and the next one are highlighted return 'This is line #3 of this snippet'; } ``` -
Mark selections of text using the
" "marker or regular expressions:"Individual // Individual terms can be highlighted, too function demo() { return 'Even regular expressions are supported'; }Markdown ```js "Individual terms" /Even.*supported/ // Individual terms can be highlighted, too function demo() { return 'Even regular expressions are supported'; } ```markdoc ```js {% meta="'Individual terms' /Even.*supported/" %} // Individual terms can be highlighted, too function demo() { return 'Even regular expressions are supported'; } ``` -
Mark text or lines as inserted or deleted with
insordel:"return function demo() { console.log('These are inserted and deleted marker types'); // The return statement uses the default marker type return true; }Markdown ```js "return true;" ins="inserted" del="deleted" function demo() { console.log('These are inserted and deleted marker types'); // The return statement uses the default marker type return true; } ```markdoc ```js {% meta="'return true;' ins='inserted' del='deleted'" %} function demo() { console.log('These are inserted and deleted marker types'); // The return statement uses the default marker type return true; } ``` -
Combine syntax highlighting with
diff-like syntax:diff function thisIsJavaScript() { // This entire block gets highlighted as JavaScript, // and we can still add diff markers to it! - console.log('Old code to be removed') + console.log('New and shiny code!') }Markdown ```diff lang="js" function thisIsJavaScript() { // This entire block gets highlighted as JavaScript, // and we can still add diff markers to it! - console.log('Old code to be removed') + console.log('New and shiny code!') } ```markdoc ```diff {% meta="lang='js'" %} function thisIsJavaScript() { // This entire block gets highlighted as JavaScript, // and we can still add diff markers to it! - console.log('Old code to be removed') + console.log('New and shiny code!') } ```
Frames and titles
Section titled âFrames and titlesâCode blocks can be rendered inside a window-like frame.
A frame that looks like a terminal window will be used for shell scripting languages (e.g. bash or sh).
Other languages display inside a code editor-style frame if they include a title.
A code blockâs optional title can be set either with a title="..." attribute following the code block's opening backticks and language identifier, or with a file name comment in the first lines of the code.
-
Add a file name tab with a comment
JavaScript // my-test-file.js console.log('Hello World!');Markdown ```js // my-test-file.js console.log('Hello World!'); ```Markdown ```js // my-test-file.js console.log('Hello World!'); ``` -
Add a title to a Terminal window
Installing dependencies⌠npm installMarkdown ```bash title="Installing dependenciesâŚ" npm install ```markdoc ```bash {% title="Installing dependenciesâŚ" %} npm install ``` -
Disable window frames with
frame="none"Bash echo "This is not rendered as a terminal despite using the bash language"Markdown ```bash frame="none" echo "This is not rendered as a terminal despite using the bash language" ```markdoc ```bash {% frame="none" %} echo "This is not rendered as a terminal despite using the bash language" ```
Details
Section titled âDetailsâDetails (also known as âdisclosuresâ or âaccordionsâ) are useful to hide content that is not immediately relevant. Users can click a short summary to expand and view the full content.
Use the standard HTML <details> and <summary> elements in your Markdown content to create a disclosure widget.
You can nest any other Markdown syntax inside a <details> element.
Where and when is the Andromeda constellation most visible?
The Andromeda constellation is most visible in the night sky during the month of November at latitudes between +90° and â40°.
<details>
<summary>Where and when is the Andromeda constellation most visible?</summary>
The [Andromeda constellation](<https://en.wikipedia.org/wiki/Andromeda_(constellation)>) is most visible in the night sky during the month of November at latitudes between `+90°` and `â40°`.
</details>Footnotes
Section titled âFootnotesâFootnotes are useful for adding brief references or clarifications without interrupting the flow of your content. They appear as numbered superscript links that jump to referenced text collected at the bottom of the page.
Define a footnote using square brackets with a caret and numbered reference:
Here is a footnote[^1] with some additional text after it.
[^1]: My reference.Other common Markdown features
Section titled âOther common Markdown featuresâStarlight supports all other Markdown authoring syntax, such as lists and tables. See the Markdown Cheat Sheet from The Markdown Guide for a quick overview of all the Markdown syntax elements.
Advanced Markdown and MDX configuration
Section titled âAdvanced Markdown and MDX configurationâStarlight renders Markdown and MDX using Astroâs configurable markdown.processor. You can add support for custom syntax and behavior by passing plugins and options to your configured processor. See âMarkdown processor pluginsâ in the Astro docs to learn more.
Markdoc
Section titled âMarkdocâStarlight supports authoring content in Markdoc using the experimental Astro Markdoc integration and the Starlight Markdoc preset.
Create a new project with Markdoc
Section titled âCreate a new project with MarkdocâStart a new Starlight project with Markdoc pre-configured using create astro:
npm create astro@latest -- --template starlight/markdocpnpm create astro --template starlight/markdocyarn create astro --template starlight/markdocAdd Markdoc to an existing project
Section titled âAdd Markdoc to an existing projectâIf you already have a Starlight site and want to add Markdoc, follow these steps.
Add Astroâs Markdoc integration:
Shell npx astro add markdocShell pnpm astro add markdocShell yarn astro add markdocInstall the Starlight Markdoc preset:
Shell npm install @astrojs/starlight-markdocShell pnpm add @astrojs/starlight-markdocShell yarn add @astrojs/starlight-markdocCreate a Markdoc configuration file at
markdoc.config.mjsand use the Starlight Markdoc preset:JavaScript import { defineMarkdocConfig } from '@astrojs/markdoc/config'; import starlightMarkdoc from '@astrojs/starlight-markdoc'; export default defineMarkdocConfig({ extends: [starlightMarkdoc()], });
To learn more about the Markdoc syntax and features, see the Markdoc documentation or the Astro Markdoc integration guide.
Configuring the Markdoc preset
Section titled âConfiguring the Markdoc presetâThe starlightMarkdoc() preset accepts the following configuration options:
headingLinks
Section titled âheadingLinksâtype: boolean
default: true
Controls whether or not headings are rendered with a clickable anchor link.
Equivalent to the markdown.headingLinks option, which applies to Markdown and MDX files.
export default defineMarkdocConfig({
// Disable the default heading anchor link support
extends: [starlightMarkdoc({ headingLinks: false })],
});