|
1 | 1 | # Links |
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.md) |
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 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: |
28 | 31 |
|
29 | 32 | ```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) |
31 | 34 | ``` |
32 | 35 |
|
33 | | -## Cross Links |
| 36 | +Note the leading `/` before the path. |
| 37 | + |
| 38 | +### Same-page links (anchors) |
34 | 39 |
|
35 | | -Cross links are links that point to a different docset. |
| 40 | +Link to sections within the same document using heading anchors prefixed with `#`: |
36 | 41 |
|
37 | 42 | ```markdown |
38 | | -[Cross link](kibana://cross-link.md) |
| 43 | +[Jump to the next section](#next-section-anchor) |
39 | 44 | ``` |
40 | 45 |
|
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: |
42 | 47 |
|
43 | | -## Auto Text Links |
| 48 | +- Converting to lowercase |
| 49 | +- Replacing spaces with hyphens |
| 50 | +- Removing special characters |
44 | 51 |
|
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: |
46 | 53 |
|
47 | 54 | ```markdown |
48 | | -[](applies.md) |
| 55 | +### Same-page links (anchors) |
| 56 | +<!-- Creates anchor #same-page-links-anchors --> |
49 | 57 | ``` |
50 | | -will output: [](applies.md) |
51 | 58 |
|
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: |
53 | 61 |
|
54 | 62 | ```markdown |
55 | | -[](applies.md#sections) |
| 63 | +## License management [manage-license] |
| 64 | +<!-- Creates anchor #manage-license instead of #license-management --> |
56 | 65 | ``` |
57 | 66 |
|
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 | +``` |
59 | 73 |
|
60 | | -This also applies to local anchors |
| 74 | +### Cross-repository links |
61 | 75 |
|
| 76 | +Link to documentation in different repositories using the `scheme://path` syntax: |
62 | 77 |
|
63 | 78 | ```markdown |
64 | | -[](#anchor-link) |
| 79 | +[Kibana API documentation](kibana://api/index.md) |
| 80 | +[Beats configuration](beats://configuration.md) |
65 | 81 | ``` |
66 | 82 |
|
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 |
68 | 86 |
|
69 | | -## Heading anchors |
| 87 | +### External links |
70 | 88 |
|
71 | | -Headings will automatically create anchor links in the resulting html. |
| 89 | +Link to websites and resources outside the Elastic docs: |
72 | 90 |
|
73 | 91 | ```markdown |
74 | | -## This Is A Header |
| 92 | +[Elastic Cloud](https://cloud.elastic.co) |
| 93 | +[Elastic Documentation](https://www.elastic.co/guide) |
75 | 94 | ``` |
76 | 95 |
|
77 | | -Will have an anchor link injected with the name `this-is-an-header`. |
| 96 | +## Link formatting |
78 | 97 |
|
| 98 | +### Style link text |
79 | 99 |
|
80 | | -If you need more control over the anchor name you may specify it inline |
| 100 | +You can include Markdown formatting within link text: |
81 | 101 |
|
82 | 102 | ```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) |
84 | 108 | ``` |
85 | 109 |
|
86 | | -Will result in an anchor link named `but-this-my-anchor` to be injected instead. |
| 110 | +### Auto-generated link text |
87 | 111 |
|
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: |
89 | 113 |
|
90 | 114 | ```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 --> |
92 | 120 | ``` |
93 | 121 |
|
94 | | -Will result in the anchor `what-about-this-for-an-anchor`. |
| 122 | +You can also auto-generate text for specific headings within files: |
95 | 123 |
|
| 124 | +```markdown |
| 125 | +[](deploy.md#scaling) |
| 126 | +<!-- Uses "Scaling" section title from deploy.md --> |
96 | 127 |
|
97 | | -## Inline anchors |
| 128 | +[](#configuration) |
| 129 | +<!-- Uses the "Configuration" section title from current file --> |
| 130 | +``` |
98 | 131 |
|
99 | | -Docsbuilder temporary supports the abbility to create a linkable anchor anywhere on any document. |
| 132 | +## Legacy features |
100 | 133 |
|
101 | | -```markdown |
102 | | -This is text and $$$this-is-an-inline-anchor$$$ |
103 | | -``` |
| 134 | +### Inline anchors |
104 | 135 |
|
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 | +``` |
0 commit comments