Skip to content

Commit 23efc52

Browse files
committed
Update linking syntax page
1 parent 19d7505 commit 23efc52

File tree

1 file changed

+82
-47
lines changed

1 file changed

+82
-47
lines changed

docs/syntax/links.md

Lines changed: 82 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,140 @@
1-
# Links
1+
# Markdown links guide
22

3-
A link contains link text (the visible text) and a link destination (the URI that is the link destination). The link text can include inline elements.
4-
5-
## Inline link
3+
A markdown link looks like this:
64

75
```markdown
8-
[Link title](links.md)
6+
[Link text](#destination)
97
```
8+
It has two components:
9+
- Link **text** enclosed in square brackets `[ ]`
10+
- Link **destination** enclosed in parentheses `( )`
1011

11-
[Link title](links.md)
12+
## Link types
1213

13-
```markdown
14-
[**Hi**, _I'm md_](links.md)
15-
```
14+
### Internal links
1615

17-
[**Hi**, _I'm md_](links.md)
16+
Link between documentation files using either relative or absolute paths.
1817

19-
## Anchor link
20-
21-
You can link to a heading on a page with an anchor link. The link destination should be a `#` followed by the header text. Convert spaces to dashes (`-`).
18+
#### Relative paths
19+
Navigate relative to the current file's location:
2220

2321
```markdown
24-
I link to the [Inline link](#inline-link) heading above.
22+
[Security documentation](../security/index.md)
23+
24+
[Monitoring guide](monitor/index.md)
2525
```
2626

27-
I link to the [Inline link](#inline-link) heading above.
27+
#### Absolute paths
28+
29+
You can also use absolute paths to link to pages:
2830

2931
```markdown
30-
I link to the [Notes](tables.md#notes) heading on the [Tables](tables.md) page.
32+
[API Keys](/deploy-manage/api-keys.md)
3133
```
3234

33-
## Cross Links
35+
### Same-page links (anchors)
3436

35-
Cross links are links that point to a different docset.
37+
Link to sections within the same document using heading anchors prefixed with `#`:
3638

3739
```markdown
38-
[Cross link](kibana://cross-link.md)
40+
[Jump to the next section](#next-section-anchor)
3941
```
4042

41-
The syntax is `<scheme>://<path>`, where <scheme> is the repository name and <path> is the path to the file.
43+
Headings will automatically create anchor links in the resulting html.
44+
45+
Heading anchors are automatically generated by:
46+
47+
- Converting to lowercase
48+
- Replacing spaces with hyphens
49+
- Removing special characters
4250

43-
## Auto Text Links
51+
For example:
4452

45-
If you link to a local markdown file but omit any link text `docs-builder` will use the target's [title](titles.md).
53+
`## Remote clusters: Cross-cluster setup!`
54+
<br>becomes<br>
55+
`#remote-clusters-cross-cluster-setup`
56+
57+
#### Custom anchors
58+
You can specify custom anchors for headings inline:
4659

4760
```markdown
48-
[](applies.md)
61+
## License management [#manage-license]
62+
<!-- Creates anchor #manage-license instead of #license-management -->
4963
```
50-
will output: [](applies.md)
5164

52-
You can go one step further to auto generate link text for headings within files:
65+
Custom anchors are also cleaned up to remove special characters and spaces, and converted to lowercase:
5366

5467
```markdown
55-
[](applies.md#sections)
68+
## API Setup [#First Time Setup!]
69+
<!-- Creates anchor #first-time-setup -->
5670
```
5771

58-
will output: [](applies.md#sections)
59-
60-
This also applies to local anchors
72+
### Cross-repository links
6173

74+
Link to documentation in different repositories using the `scheme://path` syntax:
6275

6376
```markdown
64-
[](#anchor-link)
77+
[Kibana API documentation](kibana://api/index.md)
78+
[Beats configuration](beats://configuration.md)
6579
```
6680

67-
will output: [](#anchor-link)
81+
The syntax follows the format `<scheme>://<path>`, where:
82+
- `scheme`: The target repository name (e.g., kibana, beats)
83+
- `path`: The file path within that repository
6884

69-
## Heading anchors
85+
### External links
7086

71-
Headings will automatically create anchor links in the resulting html.
87+
Link to websites and resources outside the Elastic docs:
7288

7389
```markdown
74-
## This Is A Header
90+
[Elastic Cloud](https://cloud.elastic.co)
91+
[Elastic Documentation](https://www.elastic.co/guide)
7592
```
7693

77-
Will have an anchor link injected with the name `this-is-an-header`.
94+
## Link formatting
7895

96+
### Style link text
7997

80-
If you need more control over the anchor name you may specify it inline
98+
You can include Markdown formatting within link text:
8199

82100
```markdown
83-
## This Is A Header [#but-this-is-my-anchor]
101+
[**Distributed architecture**](distributed-architecture.md)
102+
103+
[*Production guidance* and best practices](production-guidance.md)
104+
105+
[`manage-connectors.md`](manage-connectors.md)
84106
```
85107

86-
Will result in an anchor link named `but-this-my-anchor` to be injected instead.
108+
### Auto-generated link text
87109

88-
Do note that these inline anchors will be normalized.
110+
When linking to local Markdown files, you can omit the link text to automatically use the target page's title:
89111

90112
```markdown
91-
## This Is A Header [What about this for an anchor!]
113+
[](maintenance.md)
114+
<!-- Uses the title from maintenance.md -->
115+
116+
[](monitoring.md#alerting)
117+
<!-- Uses "Alerting" section title from monitoring.md -->
92118
```
93119

94-
Will result in the anchor `what-about-this-for-an-anchor`.
120+
You can also auto-generate text for specific headings within files:
95121

122+
```markdown
123+
[](deploy.md#scaling)
124+
<!-- Uses "Scaling" section title from deploy.md -->
96125

97-
## Inline anchors
126+
[](#configuration)
127+
<!-- Uses the "Configuration" section title from current file -->
128+
```
98129

99-
Docsbuilder temporary supports the abbility to create a linkable anchor anywhere on any document.
130+
## Legacy features
100131

101-
```markdown
102-
This is text and $$$this-is-an-inline-anchor$$$
103-
```
132+
### Inline anchors
104133

105-
This feature exists to aid with migration however is scheduled for removal and new content should **NOT** utilize this feature.
134+
::::{warning}
135+
This syntax exists to aid with migration. It is scheduled for removal and **should not be used** in new content.
136+
::::
137+
138+
```markdown
139+
Some text $$$custom-anchor$$$ more text
140+
```

0 commit comments

Comments
 (0)