Copy as Markdown
The Copy as Markdown action fetches the page’s .md source and writes it
to the clipboard. The user gets exactly what
the markdown route
serves — the raw markdown body by default, or flattened Markdown if you set
renderMarkdown
— without leaving the page.
When to use it
Section titled “When to use it”- Pasting docs context into an LLM chat that doesn’t have URL prefill.
- Quoting an authoritative version of a page in a PR or issue.
- Feeding markdown into local tooling (note-taking apps, scripts, etc.).
Configuration
Section titled “Configuration”copyMarkdown is on by default. To disable it:
starlightLlmActions({ actions: { copyMarkdown: false, },})When disabled, the action is removed from the dropdown.
How it works
Section titled “How it works”The action runs entirely in the browser:
- The dropdown item resolves the page’s markdown URL using
markdownUrl(default/{slug}.md). - A
fetch()request retrieves the markdown. - The response body is written to the clipboard via the Async Clipboard API.
If the user’s browser blocks clipboard writes (e.g. on http:// origins
without explicit permission), the action falls back to selecting the
markdown into a hidden textarea and using document.execCommand('copy').
When the action isn’t there
Section titled “When the action isn’t there”Copy as Markdown only appears on pages that have a Markdown route to fetch.
A page outside every collection named in
collections
gets no .md file, so the item is dropped rather than fetching a 404. View as
Markdown goes with it; the Open in… providers stay, falling back to the
page’s own URL.
Modifying what gets copied
Section titled “Modifying what gets copied”The action copies whatever the markdown route serves. To change the copied
content, point markdownUrl at a different route:
starlightLlmActions({ markdownUrl: '/raw/{slug}.txt', injectRoute: false, // your route already serves the content})See markdownUrl
and injectRoute
for the full options.
See also
Section titled “See also”- View as Markdown — opens the markdown URL in the browser instead of copying.
- Open in… — sends the page (or a prompt referencing it) directly to an LLM.