docs/manual/guide/09-links.org
324 lines · 17248 bytes
1#+TITLE: Links
2#+DESCRIPTION: Link syntax, the link types Orgstar follows, storing and inserting links, IDs, backlinks and inline images.
3#+LEDE: Write links as Org does, follow them with a key or a click, and see which headings link to the one you are reading.
4
5* Link syntax
6
7Orgstar reads links the way =org-element-link-parser= does. There are three forms.
8
9| Form | Example | Notes |
10|---------------+-------------------------------------------+-------------------------------------------------------------|
11| Bracket link | =[[https://orgmode.org][Org website]]= | Any link type. The description after =][= is optional. |
12| Angle link | =<https://orgmode.org>= | For =http=, =https=, =mailto=, =file=, =id=, =doi=, =ftp=, =news=, =shell=, =elisp=, =info=, =help= and =attachment=. |
13| Plain link | =https://orgmode.org= | Only =https://=, =http://=, =mailto:= and =file:= are recognized in running text. |
14
15Inside a bracket link, a target that starts with =/=, =~=, =./= or =../= is a file
16link. A target in parentheses, =(name)=, is a coderef. One that starts with =#= is a
17custom ID. Anything without a known =type:= prefix is a search for text in the
18current file (a "fuzzy" link). A link may run over a line break; the break and
19surrounding blanks read as one space.
20
21Backslashes before brackets are escaped as in =org-link-escape=: when Orgstar writes
22a link it doubles backslashes that come before a bracket or the end, and it reads them
23back the same way.
24
25* How links display
26
27With View ▸ Show Markup off (the default, =⇧⌘M= toggles it), a link with a
28description shows only its description, and its brackets and target are hidden. This
29is =org-link-descriptive=. The full text appears on the line that holds the caret, so
30you can edit it. With Show Markup on, every link shows as written. The setting is
31=show-markup= under =[orgstar]= in the config file (see
32[[file:13-configuration.org][Configuration]]).
33
34Links without a description show their target, with the brackets hidden in the same
35way. Radio targets (=<<<words>>>=) turn every other occurrence of those words in the
36file into a link, matched case-insensitively, as in Org.
37
38* Following links
39
40=org-open-at-point= follows the link at the caret, or opens the agenda for a timestamp.
41
42| Preset | Key |
43|--------+---------------------------------------------------------------------------------------|
44| Emacs | =C-c C-o= |
45| Mac | Org ▸ Open Link (no key by default) |
46| Doom | =C-c C-o= in any state; =RET= in normal state follows a link before doing anything else |
47| All | =⌘=-click on the link; =o= at the start of a heading line when speed commands are on |
48
49A message in the echo area explains a link that can't be followed.
50
51** What each link type does
52
53| Link | Example | Result |
54|----------------------------------------------+--------------------------------------+--------------------------------------------------------------------------------------------|
55| =http=, =https=, =ftp=, =news=, =mailto= | =[[mailto:me@example.com]]= | Opened by macOS in your default browser or mail app. |
56| =doi= | =[[doi:10.1000/182]]= | Opens =https://doi.org/= followed by the DOI. |
57| =file= (also =file+sys:=, =file+emacs:=) | =[[file:notes.org::*Ideas]]= | See /File links/ below. |
58| =id= | =[[id:6A3C…]]= | Opens the file with the heading whose =ID= property matches, and moves to the heading. |
59| Custom ID | =[[#setup]]= | Moves to the heading in this file whose =CUSTOM_ID= property is =setup=. |
60| Heading | =[[*Weekly review]]= | Moves to the heading in this file with that title. |
61| Text | =[[budget table]]= | Searches this file: a =<<budget table>>= target, then =#+NAME: budget table=, then a heading. |
62| Coderef | =[[(ref)]]= | Not supported. The echo area says so. |
63| =shell=, =elisp= | =[[shell:ls]]= | Not run. Orgstar never executes these links. |
64| =attachment=, =info=, =help=, others | | Not followed. The echo area says Orgstar can't open the type. |
65
66The text search follows =org-link-search=. A dedicated =<<target>>= matches its words
67case-insensitively, with any run of blanks between them. A heading matches when its
68title, with statistics cookies such as =[2/5]= and a leading =COMMENT= removed, has the
69same words as the link, ignoring case. A search that starts with =*= looks at headings
70only. Regular-expression searches (=/re/=) are not supported.
71
72Following a radio link looks for a dedicated target, a name or a heading with the same
73text. It does not jump to the =<<<radio target>>>= itself.
74
75** File links
76
77A relative path is resolved against the folder of the file that holds the link, as
78Org does; =~= is your home folder; an absolute path is used as written. Links between
79files in different sidebar folders work the same way, for example
80=[[file:../work/projects.org]]= or =[[file:~/Documents/org/inbox.org]]=.
81
82What happens depends on the file:
83
84- An =.org= or =.org_archive= file opens as a buffer in Orgstar.
85- Another text file opens in Orgstar as a plain buffer.
86- Anything else (images, PDFs, archives, media) is handed to macOS, which opens it in
87 the default app for that type.
88
89If the file doesn't exist, the echo area shows =No file= and the path.
90
91After =::=, a file link can carry a search option:
92
93| Option | Example | Moves to |
94|-----------------+----------------------------------+---------------------------------------------|
95| A number | =[[file:log.txt::120]]= | Line 120. |
96| =*Title= | =[[file:notes.org::*Ideas]]= | The heading with that title. |
97| =#custom-id= | =[[file:notes.org::#setup]]= | The heading with that =CUSTOM_ID=. |
98| Other text | =[[file:notes.org::budget]]= | A target, a =#+NAME= or a heading, as above. |
99
100** id links
101
102=id:= links are resolved through the index, so the target heading must be in a file
103under one of your sidebar folders. A link to an ID that isn't indexed shows =No heading
104has the ID= followed by the ID.
105
106** Timestamps
107
108=C-c C-o= or =⌘=-click on a timestamp opens the agenda on that day, as
109=org-follow-timestamp-link= does. On a date range such as
110=<2026-10-05 Mon>--<2026-10-09 Fri>=, the agenda shows the whole span. See
111[[file:07-agenda.org][Agenda]].
112
113* Inserting and editing links
114
115=org-insert-link= asks for a link and a description in the echo area.
116
117| Preset | Key |
118|--------+------------------------------|
119| Emacs | =C-c C-l= |
120| Mac | Org ▸ Insert Link… |
121| Doom | =SPC m l l=, or =C-c C-l= |
122
123The first prompt reads =Insert link:=, or =Insert link (default …):= when you have
124stored links. It completes from:
125
126- your stored links, most recent first, and their descriptions;
127- the link abbreviations defined in the file (see /Link abbreviations/);
128- the link types =id=, =eww=, =rmail=, =mhe=, =irc=, =info=, =gnus=, =docview=,
129 =bibtex=, =bbdb=, =w3m=, =doi=, =file+sys=, =file+emacs=, =shell=, =news=, =mailto=,
130 =https=, =http=, =ftp=, =shortdoc=, =help=, =file= and =elisp=, each followed by =:=.
131
132Pressing Return on an empty answer inserts the most recent stored link. Choosing a
133description inserts the link it belongs to. If you choose a bare type such as =https:=,
134a second prompt, =Link (no completion support):=, asks for the rest.
135
136The next prompt, =Description:=, offers the stored link's description, or the
137selected text if you selected some before running the command. An empty description
138inserts a link without one. With text selected, the link replaces the selection.
139
140When the caret is on an existing link, the same command edits it: the =Link:= prompt
141starts with the current target and =Description:= with the current description.
142
143A stored link that you insert is removed from the stored list, as with
144=org-link-keep-stored-after-insertion= set to nil.
145
146** File paths in inserted links
147
148When the inserted link is a =file:= link, Orgstar rewrites it as
149=org-link-make-string-for-buffer= does:
150
151- A link to a heading or target in the file you are editing loses its =file:= part
152 and keeps only the search, for example =[[*Ideas]]=.
153- A path under the current file's folder becomes relative to it.
154- Any other path is written with =~= for your home folder.
155
156** Completion while typing
157
158You can also type a link by hand. With the caret right after =[[=, completion at point
159offers =attachment:=, =doi:=, =file:=, =http:=, =https:=, =id:= and =mailto:=, plus
160the file's link abbreviations. After =[[*=, it offers the headings of the current file.
161Completion at point is =C-M-i= in the Emacs preset and =C-SPC= in Doom's insert state;
162see [[file:02-the-editor.org][The editor]].
163
164* Storing links
165
166=org-store-link= remembers a link to where the caret is, for a later Insert Link.
167
168| Preset | Key |
169|--------+---------------------------------------|
170| Emacs | =C-c l= |
171| Mac | Org ▸ Store Link |
172| Doom | =SPC m l s= or =SPC n l= |
173
174The stored link is a =file:= link to the current file, written with =~= for your home
175folder, followed by a search option chosen as Org does with
176=org-link-context-for-files= on:
177
1781. If the caret touches a =<<target>>= on its line, the link points at the target.
1792. Otherwise, if text is selected, the link searches for that text.
1803. Otherwise, if the caret is in an element with a =#+NAME=, the link uses the name.
1814. Otherwise, inside a heading's entry, the link uses =#custom-id= if the heading has a
182 =CUSTOM_ID= property, and =*Title= if not. The title becomes the description.
1835. Before the first heading, the link searches for the text of the current line.
184
185The echo area shows =Stored:= and the description or link. Storing the same link again
186moves it to the front of the list. Stored links last until you quit Orgstar; they
187aren't saved between sessions, as in Emacs.
188
189* IDs
190
191Org identifies headings across files with an =ID= property. Two commands manage it.
192
193| Command | Org function | Keys |
194|-----------------------+---------------------------------------+-----------------------------------|
195| Org ▸ Create ID | =org-id-get-create= | No default key |
196| Org ▸ Store ID Link | =org-id-get-create= + =org-id-store-link= | Doom =SPC m l i=; no key in Emacs or Mac |
197
198Create ID gives the heading at the caret an =ID= property if it doesn't have one. The
199ID is a new UUID in upper case, for example =6A3C2F9E-…=. Before the first heading,
200the property goes into the file-level property drawer.
201
202Store ID Link does the same, then stores an =id:= link to the heading with its title
203as the description. Before the first heading, the description is the =#+TITLE=, or
204the file name. If the caret is on a target or named element inside the entry, the
205link carries that search, as =id:…::search=, which mirrors =org-id-link-use-context=.
206
207=CUSTOM_ID= is a property you set yourself, with the property commands in
208[[file:04-outlines.org][Outlines]]. Link to it with =[[#name]]= in the same file or
209=[[file:other.org::#name]]= from another. Store Link uses it when the heading has one.
210
211* Targets and radio targets
212
213=<<target>>= marks a place in the text that a link with the same words reaches:
214=[[target]]=. Store Link with the caret on a target stores a link to it.
215
216=<<<radio target>>>= makes every other occurrence of its words in the file a link,
217matched case-insensitively and between non-word characters. Radio links are
218highlighted as links and exported as links to the target (see
219[[file:12-export.org][Export]]). Following one in the editor does not reach the
220radio target; see /What each link type does/.
221
222* Link abbreviations
223
224A =#+LINK:= line defines an abbreviation, as =org-link-abbrev-alist-local= does:
225
226#+BEGIN_SRC org
227,#+LINK: gh https://github.com/%s
228,#+LINK: search https://duckduckgo.com/?q=%h
229,#+LINK: wiki https://en.wikipedia.org/wiki/
230
231[[gh:orgmode/org-mode]] → https://github.com/orgmode/org-mode
232[[search:org tables]] → https://duckduckgo.com/?q=org%20tables
233[[wiki:Org-mode]] → https://en.wikipedia.org/wiki/Org-mode
234#+END_SRC
235
236In the template, =%s= is replaced by the text after the colon, =%h= by the same text
237percent-encoded, and a template with neither has the text appended. Function
238templates (=%(…)=) are not supported. Abbreviations from a =#+SETUPFILE= count too.
239When a key is defined twice, the first definition wins.
240
241* The backlinks pane
242
243View ▸ Show or Hide Backlinks shows a pane beside the editor of an org file. It has
244two sections:
245
246- *Links to* the heading at the caret, named after that heading.
247- *Links to this file*.
248
249Each row shows the linking heading and its file name. Click a row to open it. The
250pane is shown by default and updates as you move the caret and edit.
251
252The pane looks at every org file in your sidebar folders, including unsaved changes
253in open buffers. A link counts when following it would lead to the heading or the
254file:
255
256- =id:= links to the heading's =ID=;
257- =file:= links and plain paths (=./=, =../=, =/=, =~/=) to the file, with no search
258 option for the file section, or with =::*Title=, =::#custom-id= or =::Title= for a
259 heading;
260- within the same file, =[[*Title]]=, =[[#custom-id]]= and =[[Title]]=.
261
262Links to targets, names and line numbers are not counted. Only links inside a heading's
263entry are indexed, so links in the text before a file's first heading don't appear.
264A heading's links to itself are left out.
265
266* Inline images
267
268=org-toggle-inline-images= shows image links as images.
269
270| Preset | Key |
271|--------+----------------------------------------------|
272| Emacs | =C-c C-x C-v= |
273| Mac | Org ▸ Show or Hide Inline Images |
274| Doom | =C-c C-x C-v= |
275
276The echo area reports how many images are shown, or that inline display is off.
277
278A line shows an image when it holds nothing but a bracket link, without a description,
279to a file ending in =.png=, =.jpg=, =.jpeg=, =.gif=, =.svg=, =.webp=, =.tif=, =.tiff=,
280=.bmp=, =.heic= or =.avif= (in any case):
281
282#+BEGIN_SRC org
283[[file:images/diagram.png]]
284[[./photo.jpg]]
285#+END_SRC
286
287Relative paths are resolved against the file's folder. Web addresses and
288=attachment:= links are not shown as images. The link text is hidden while the image
289is shown, except on the line that holds the caret.
290
291** Sizing
292
293An image is drawn at its own width, up to the width of the text area. To set a width,
294put =#+ATTR_ORG: :width= with a number of points among the keywords above the link:
295
296#+BEGIN_SRC org
297,#+CAPTION: Network layout
298,#+ATTR_ORG: :width 300
299[[file:images/network.png]]
300#+END_SRC
301
302The height follows the image's proportions. =#+ATTR_HTML= and other exporters'
303attributes don't affect the editor.
304
305** Showing images when a file opens
306
307The config key =org-startup-with-inline-images= (default =false=) shows images in
308every file when it opens. In a file, =#+STARTUP: inlineimages= or
309=#+STARTUP: noinlineimages= overrides it.
310
311* org-protocol store-link
312
313Orgstar handles =org-protocol://store-link= URLs, in the new form
314~org-protocol://store-link?url=…&title=…~ and the old form
315=org-protocol://store-link:/URL/TITLE=. The URL is added to your stored links with
316the title as its description, and is also copied to the clipboard. Insert it with
317Insert Link. Setting up a browser bookmarklet, and =org-protocol://capture=, are in
318[[file:08-capture.org][Capture]].
319
320* On iOS
321
322The iOS app follows links: tap a link in the reader. Org files open in the app, and
323web, mail and other files go to the system. Storing and inserting links, the backlinks
324pane and inline images are Mac features. See [[file:14-ios.org][iOS]].