# Copy as Markdown

> Copy the current page's markdown source to the clipboard.

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](/starlight-llm-actions/getting-started/concepts/#the-markdown-route) serves — the raw markdown body by default, or flattened Markdown if you set [`renderMarkdown`](/starlight-llm-actions/configuration/reference/#rendermarkdown) — without leaving the page.

## 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

`copyMarkdown` is on by default. To disable it:

```js
starlightLlmActions({
  actions: {
    copyMarkdown: false,
  },
})
```

When disabled, the action is removed from the dropdown.

## How it works

The action runs entirely in the browser:

1. The dropdown item resolves the page’s markdown URL using `markdownUrl` (default `/{slug}.md`).
2. A `fetch()` request retrieves the markdown.
3. The response body is written to the clipboard via the [Async Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/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

**Copy as Markdown** only appears on pages that have a Markdown route to fetch. A page outside every collection named in [`collections`](/starlight-llm-actions/configuration/reference/#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

The action copies whatever the markdown route serves. To change the copied content, point `markdownUrl` at a different route:

```js
starlightLlmActions({
  markdownUrl: '/raw/{slug}.txt',
  injectRoute: false, // your route already serves the content
})
```

See [`markdownUrl`](/starlight-llm-actions/configuration/reference/#markdownurl) and [`injectRoute`](/starlight-llm-actions/configuration/reference/#injectroute) for the full options.

## See also

* [View as Markdown](/starlight-llm-actions/actions/view/) — opens the markdown URL in the browser instead of copying.
* [Open in…](/starlight-llm-actions/actions/open-in/) — sends the page (or a prompt referencing it) directly to an LLM.