# Discovery and sharing

Docskit generates `sitemap.xml`, `robots.txt`, and Markdown exports during a build.
Documentation pages include **Copy page** and **Markdown** actions. Add an edit
URL to help readers correct live pages on GitHub.

## Generate a sitemap

Set `url` and `basePath` to match the deployed site. Sitemap generation is enabled
by default and includes the custom homepage, configured standalone pages, and canonical
documentation URLs:

```ts title="docskit.config.ts"
url: "https://docs.example.com",
basePath: "/",
sitemap: true,
robots: true,
```

Once a stable version exists, the sitemap includes its documentation and omits
Next and archived versions. Those omitted versions receive `noindex, follow`
metadata. Before the first stable release, Next is included. Alternate URLs for
the same version resolve to one canonical sitemap entry.

To make Next or archived versions indexable, opt in:

```ts
sitemap: {
  includeNext: true,
  includeArchives: true,
},
```

Use `sitemap: false` or `robots: false` to disable either generated file, for
example when you supply your own in `public/`. `robots.txt` references the
sitemap's absolute URL when sitemap generation is enabled. It allows crawlers
to read pages so they can see the `noindex` metadata.

For a site under `/project/`, the build writes `dist/sitemap.xml`, whose page
URLs include `/project/`. Robots rules are read from the origin's `/robots.txt`;
if your host serves this build only under `/project/`, add the sitemap reference
to the origin's robots file separately.

## Export Markdown for readers and tools

Markdown exports are enabled by default. Each documentation version gets its own
files, with links pointing to that version's canonical pages:

| File                       | Contents                                                    |
| -------------------------- | ----------------------------------------------------------- |
| `/docs/index.md`           | The documentation overview                                  |
| `/docs/guides/install.md`  | The page at `/docs/guides/install/`, if it exists           |
| `/api-references/index.md` | The API overview, if it exists                              |
| `/llms.txt`                | An index of documentation and API pages, with Markdown URLs |
| `/llms-full.txt`           | The text of those pages in one file                         |

These paths are relative to the version's base path. Next has
`/next/llms.txt`; an archive might have `/v/0.1/llms.txt`. Each file contains one
version's content. Pending and superseded snapshots are not exported.

**Copy page** copies a page's Markdown to the clipboard. **Markdown** downloads
that file. The exports retain headings, links, images, tables, math, and fenced
code. Code tab labels become headings. Frontmatter, imports, JSX wrappers, and
JavaScript expressions are removed. Content produced only by a custom React
component is not evaluated or included. Standalone React pages have no Markdown
export.

Set `markdown: false` to disable Markdown files, both LLM files, and the page
copy/download actions:

```ts
markdown: false,
```

Generated files are also available in development and refresh when source files
change. Production exports are static files and require no server.

## Add an edit link

Set `editLink.pattern` to an HTTP or HTTPS URL containing `:path`. Docskit replaces
that placeholder with the content-relative source filename, including `.md`:

```ts title="docskit.config.ts"
editLink: {
  pattern: "https://github.com/your-org/your-repo/edit/main/docs/content/:path",
  text: "Edit this page",
},
```

Replace the owner, repository, branch, and content directory with your own. For
`content/guides/install.md`, `:path` becomes `guides/install.md`. The default
label is **Edit this page**; omit `text` to use it.

Editing is available only on live content. Stable and archived snapshots have
no edit link because they are frozen. Generated API pages also omit the link;
update their TypeScript source instead. Set `editLink: false` to disable editing.

## Exclude a page from discovery

Set `noIndex: true` in a Markdown page's frontmatter:

```md
---
title: Internal notes
description: Notes linked directly from another page.
noIndex: true
---
```

The HTML receives `noindex, follow`, and the page is omitted from the sitemap
and LLM indexes. Its route and Markdown file remain accessible. This option
does not provide access control or remove the page from site search.

## Check the output

Run `pnpm build` and `pnpm preview` from your docs project. Open `sitemap.xml`,
`robots.txt`, and `llms.txt` at the deployment base path. Follow a Markdown link,
try **Copy page**, and check that Next's edit links point to the expected branch
and source filename.

Source: https://docskit.pinanek.me/docs/publishing/discovery-and-sharing/
