Skip to content

Commit 100ec31

Browse files
authored
Update linking syntax page (#415)
1 parent 2fd596b commit 100ec31

File tree

2 files changed

+83
-46
lines changed

2 files changed

+83
-46
lines changed

docs/syntax/links.md

Lines changed: 82 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,142 @@
11
# Links
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.md)
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 within the same repository.
30+
Say you're working on a random page somewhere in the `docs-content` repo. You can link to a page in the `deploy-manage` section like this:
2831

2932
```markdown
30-
I link to the [Notes](tables.md#notes) heading on the [Tables](tables.md) page.
33+
[API Keys](/deploy-manage/api-keys.md)
3134
```
3235

33-
## Cross Links
36+
Note the leading `/` before the path.
37+
38+
### Same-page links (anchors)
3439

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

3742
```markdown
38-
[Cross link](kibana://cross-link.md)
43+
[Jump to the next section](#next-section-anchor)
3944
```
4045

41-
The syntax is `<scheme>://<path>`, where <scheme> is the repository name and <path> is the path to the file.
46+
Headings will automatically create anchor links in the resulting HTML. They are automatically generated by:
4247

43-
## Auto Text Links
48+
- Converting to lowercase
49+
- Replacing spaces with hyphens
50+
- Removing special characters
4451

45-
If you link to a local markdown file but omit any link text `docs-builder` will use the target's [title](titles.md).
52+
For example:
4653

4754
```markdown
48-
[](applies.md)
55+
### Same-page links (anchors)
56+
<!-- Creates anchor #same-page-links-anchors -->
4957
```
50-
will output: [](applies.md)
5158

52-
You can go one step further to auto generate link text for headings within files:
59+
#### Custom anchors
60+
You can specify custom anchors for headings inline:
5361

5462
```markdown
55-
[](applies.md#sections)
63+
## License management [manage-license]
64+
<!-- Creates anchor #manage-license instead of #license-management -->
5665
```
5766

58-
will output: [](applies.md#sections)
67+
Custom anchors are also cleaned up to remove special characters and spaces, and converted to lowercase:
68+
69+
```markdown
70+
## API Setup [First Time Setup!]
71+
<!-- Creates anchor #first-time-setup -->
72+
```
5973

60-
This also applies to local anchors
74+
### Cross-repository links
6175

76+
Link to documentation in different repositories using the `scheme://path` syntax:
6277

6378
```markdown
64-
[](#anchor-link)
79+
[Kibana API documentation](kibana://api/index.md)
80+
[Beats configuration](beats://configuration.md)
6581
```
6682

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

69-
## Heading anchors
87+
### External links
7088

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

7391
```markdown
74-
## This Is A Header
92+
[Elastic Cloud](https://cloud.elastic.co)
93+
[Elastic Documentation](https://www.elastic.co/guide)
7594
```
7695

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

98+
### Style link text
7999

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

82102
```markdown
83-
## This Is A Header [#but-this-is-my-anchor]
103+
[**Distributed architecture**](distributed-architecture.md)
104+
105+
[*Production guidance* and best practices](production-guidance.md)
106+
107+
[`manage-connectors.md`](manage-connectors.md)
84108
```
85109

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

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

90114
```markdown
91-
## This Is A Header [What about this for an anchor!]
115+
[](maintenance.md)
116+
<!-- Uses the title from maintenance.md -->
117+
118+
[](monitoring.md#alerting)
119+
<!-- Uses "Alerting" section title from monitoring.md -->
92120
```
93121

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

124+
```markdown
125+
[](deploy.md#scaling)
126+
<!-- Uses "Scaling" section title from deploy.md -->
96127

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

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

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

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

docs/syntax/titles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This title is used both by the documentation navigation
1717
* Left hand site
1818
* Navigational elements such as breadcrumbs and previous/next links.
1919

20-
As well as when using the [auto text links](./links.md#auto-text-links), e.g:
20+
As well as when using the [auto text links](./links.md#same-page-links-anchors), e.g:
2121

2222
```markdown
2323
[](titles.md)

0 commit comments

Comments
 (0)