|
1 | | -# Links |
| 1 | +# Markdown links guide |
2 | 2 |
|
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: |
6 | 4 |
|
7 | 5 | ```markdown |
8 | | -[Link title](links.md) |
| 6 | +[Link text](#destination) |
9 | 7 | ``` |
| 8 | +It has two components: |
| 9 | +- Link **text** enclosed in square brackets `[ ]` |
| 10 | +- Link **destination** enclosed in parentheses `( )` |
10 | 11 |
|
11 | | -[Link title](links.md) |
| 12 | +## Link types |
12 | 13 |
|
13 | | -```markdown |
14 | | -[**Hi**, _I'm md_](links.md) |
15 | | -``` |
| 14 | +### Internal links |
16 | 15 |
|
17 | | -[**Hi**, _I'm md_](links.md) |
| 16 | +Link between documentation files using either relative or absolute paths. |
18 | 17 |
|
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: |
22 | 20 |
|
23 | 21 | ```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) |
25 | 25 | ``` |
26 | 26 |
|
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: |
28 | 30 |
|
29 | 31 | ```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) |
31 | 33 | ``` |
32 | 34 |
|
33 | | -## Cross Links |
| 35 | +### Same-page links (anchors) |
34 | 36 |
|
35 | | -Cross links are links that point to a different docset. |
| 37 | +Link to sections within the same document using heading anchors prefixed with `#`: |
36 | 38 |
|
37 | 39 | ```markdown |
38 | | -[Cross link](kibana://cross-link.md) |
| 40 | +[Jump to the next section](#next-section-anchor) |
39 | 41 | ``` |
40 | 42 |
|
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 |
42 | 50 |
|
43 | | -## Auto Text Links |
| 51 | +For example: |
44 | 52 |
|
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: |
46 | 59 |
|
47 | 60 | ```markdown |
48 | | -[](applies.md) |
| 61 | +## License management [#manage-license] |
| 62 | +<!-- Creates anchor #manage-license instead of #license-management --> |
49 | 63 | ``` |
50 | | -will output: [](applies.md) |
51 | 64 |
|
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: |
53 | 66 |
|
54 | 67 | ```markdown |
55 | | -[](applies.md#sections) |
| 68 | +## API Setup [#First Time Setup!] |
| 69 | +<!-- Creates anchor #first-time-setup --> |
56 | 70 | ``` |
57 | 71 |
|
58 | | -will output: [](applies.md#sections) |
59 | | - |
60 | | -This also applies to local anchors |
| 72 | +### Cross-repository links |
61 | 73 |
|
| 74 | +Link to documentation in different repositories using the `scheme://path` syntax: |
62 | 75 |
|
63 | 76 | ```markdown |
64 | | -[](#anchor-link) |
| 77 | +[Kibana API documentation](kibana://api/index.md) |
| 78 | +[Beats configuration](beats://configuration.md) |
65 | 79 | ``` |
66 | 80 |
|
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 |
68 | 84 |
|
69 | | -## Heading anchors |
| 85 | +### External links |
70 | 86 |
|
71 | | -Headings will automatically create anchor links in the resulting html. |
| 87 | +Link to websites and resources outside the Elastic docs: |
72 | 88 |
|
73 | 89 | ```markdown |
74 | | -## This Is A Header |
| 90 | +[Elastic Cloud](https://cloud.elastic.co) |
| 91 | +[Elastic Documentation](https://www.elastic.co/guide) |
75 | 92 | ``` |
76 | 93 |
|
77 | | -Will have an anchor link injected with the name `this-is-an-header`. |
| 94 | +## Link formatting |
78 | 95 |
|
| 96 | +### Style link text |
79 | 97 |
|
80 | | -If you need more control over the anchor name you may specify it inline |
| 98 | +You can include Markdown formatting within link text: |
81 | 99 |
|
82 | 100 | ```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) |
84 | 106 | ``` |
85 | 107 |
|
86 | | -Will result in an anchor link named `but-this-my-anchor` to be injected instead. |
| 108 | +### Auto-generated link text |
87 | 109 |
|
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: |
89 | 111 |
|
90 | 112 | ```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 --> |
92 | 118 | ``` |
93 | 119 |
|
94 | | -Will result in the anchor `what-about-this-for-an-anchor`. |
| 120 | +You can also auto-generate text for specific headings within files: |
95 | 121 |
|
| 122 | +```markdown |
| 123 | +[](deploy.md#scaling) |
| 124 | +<!-- Uses "Scaling" section title from deploy.md --> |
96 | 125 |
|
97 | | -## Inline anchors |
| 126 | +[](#configuration) |
| 127 | +<!-- Uses the "Configuration" section title from current file --> |
| 128 | +``` |
98 | 129 |
|
99 | | -Docsbuilder temporary supports the abbility to create a linkable anchor anywhere on any document. |
| 130 | +## Legacy features |
100 | 131 |
|
101 | | -```markdown |
102 | | -This is text and $$$this-is-an-inline-anchor$$$ |
103 | | -``` |
| 132 | +### Inline anchors |
104 | 133 |
|
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