﻿---
title: Cross-links
description: All build modes — isolated, assembler, and codex — support cross-linking between documentation sets. Cross-links let you reference pages in other repositories...
url: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/5111/documentation/cross-links
products:
  - Elastic Docs Builder
---

# Cross-links
All build modes — [isolated](https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/5111/documentation/isolated), [assembler](https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/5111/documentation/assembler), and [codex](https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/5111/documentation/codex) — support cross-linking between documentation sets. Cross-links let you reference pages in other repositories using a validated, portable syntax instead of hardcoded URLs.

## Syntax

```markdown
[Getting started with Elasticsearch](elasticsearch://reference/getting-started.md)
```

The format is `<repository>://<path-to-file>`. The repository name matches the GitHub repository name without the org prefix. You can also link to specific headings:
```markdown
[Query DSL](elasticsearch://reference/query-dsl.md#match-query)
```


## Declaring dependencies

Before using cross-links, declare the target repositories in your `docset.yml`:
```yaml
cross_links:
  - elasticsearch
  - kibana
  - docs-content
```

This tells docs-builder to fetch the link index for each listed repository so it can validate your cross-links at build time — even during local development.
<tip>
  Only list repositories you actually link to. Each entry adds a link-index fetch during builds.
</tip>


## How validation works

```mermaid
sequenceDiagram
    participant MD as Markdown file
    participant DB as docs-builder
    participant LS as Link Service
    MD->>DB: elasticsearch://reference/api.md
    DB->>LS: Fetch elasticsearch link index
    LS-->>DB: links.json
    DB->>DB: Look up path in index
    DB-->>MD: Resolved URL
```

1. **Fetch** — downloads the target repository's link index from the link service
2. **Look up** — checks that the referenced path (and anchor, if specified) exists in the index
3. **Resolve** — replaces the cross-link with the correct URL for the current build mode
4. **Error** — produces a build error if the target doesn't exist

The resolved URL depends on context — in isolated builds it points to the live site, in assembler builds it resolves to the local path within the unified output.

## When a link index is not available

In [isolated](https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/5111/documentation/isolated) and [codex](https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/5111/documentation/codex) builds, when docs-builder cannot fetch the link index of a repository listed under `cross_links`, it reports one diagnostic on `docset.yml`. It does not report an error for every link. The diagnostic is:
- an **error** when at least one page links to that repository
- a **warning** when no page links to it, because no cross-link went unvalidated

The affected cross-links are not validated. Each one renders as the path you wrote, with its anchor, and docs-builder does not check that the page or anchor exists. The next build compiles every page again, so it validates them once access is back.
To restore access, fix the cause that the diagnostic names:
- **Locally**, run `docs-builder codex clone` first, or make sure you can reach `git@github.com:elastic/codex-link-index.git` over SSH.
- **In CI**, give the job a `GITHUB_TOKEN` that can read `elastic/codex-link-index`. Jobs for pull requests from forks do not receive the token that grants this, so push the branch to the upstream repository.
- **For a repository that is missing from the index**, check the name under `cross_links`, and check that the repository has published its link index.

[Assembler](https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/5111/documentation/assembler) builds fetch their link indexes from `assembler.yml` and stop when a fetch fails. They produce no diagnostic and no fallback links.
To skip the fetch on purpose, pass `--skip-cross-links` to the isolated build. That validates no cross-link in the build. Use it for a quick check, not for a build that gates a merge.

## Inbound link validation

You can check whether changes to your documentation would break links **from** other repositories:
```bash
docs-builder inbound-links validate-link-reference
docs-builder inbound-links validate-all
```

This downloads all published link indexes and checks if any of them reference pages you've moved or deleted. Common scenarios:
- **Renaming a page** — other repos may link to the old path
- **Removing a heading** — a heading change can break fragment links from other repos
- **Reorganizing structure** — moving files between directories invalidates existing cross-links

When inbound validation fails, it reports which repos and files contain the broken references, so you can coordinate fixes or add [redirects](https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/5111/documentation/redirects).
For how all of this is enabled by the distributed build model, see [distributed builds](https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/5111/documentation/distributed-builds).