docs/manual/guide/09-links.org

416 lines · 23674 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    | =⌃⌘O=                                                                                 |
 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)]]=                          | Moves to the label =(ref:ref)= in a src or example block; see /Code references/ below.      |
 63| Regexp                                       | =[[/TODO.*soon/]]=                   | Shows a sparse tree of the regular expression's matches, as =org-occur=; iOS moves to the first match. |
 64| =shell=, =elisp=                             | =[[shell:ls]]=                       | Not run. orgstar never executes these links.                                               |
 65| =attachment=                                 | =[[attachment:scan.pdf]]=            | Opens the file in the entry's attachment folder; see /Attachment links/ below.             |
 66| Radio link                                   | Text matching a =<<<radio target>>>= | Moves to the radio target.                                                                 |
 67| =info=, =help=, others                       |                                      | Not followed. The echo area says orgstar can't open the type.                              |
 68
 69The text search follows =org-link-search=. A dedicated =<<target>>= matches its words
 70case-insensitively, with any run of blanks between them. A heading matches when its
 71title, with statistics cookies such as =[2/5]= and a leading =COMMENT= removed, has the
 72same words as the link, ignoring case. A search that starts with =*= looks at headings
 73only. Regular-expression searches (=/re/=) are not supported.
 74
 75Following a radio link moves to its =<<<radio target>>>=, matching the words without
 76regard to case, as =org-link--search-radio-target= does. When the target is gone, the
 77echo area shows =No match for radio target:= and the text.
 78
 79** File links
 80
 81A relative path is resolved against the folder of the file that holds the link, as
 82Org does; =~= is your home folder; an absolute path is used as written. Links between
 83files in different sidebar folders work the same way, for example
 84=[[file:../work/projects.org]]= or =[[file:~/Documents/org/inbox.org]]=.
 85
 86What happens depends on the file:
 87
 88- An =.org= or =.org_archive= file opens as a buffer in orgstar.
 89- Another text file opens in orgstar as a plain buffer.
 90- Anything else (images, PDFs, archives, media) is handed to macOS, which opens it in
 91  the default app for that type.
 92
 93If the file doesn't exist, the echo area shows =No file= and the path.
 94
 95After =::=, a file link can carry a search option:
 96
 97| Option          | Example                          | Moves to                                    |
 98|-----------------+----------------------------------+---------------------------------------------|
 99| A number        | =[[file:log.txt::120]]=          | Line 120.                                   |
100| =*Title=        | =[[file:notes.org::*Ideas]]=     | The heading with that title.                |
101| =#custom-id=    | =[[file:notes.org::#setup]]=     | The heading with that =CUSTOM_ID=.          |
102| Other text      | =[[file:notes.org::budget]]=     | A target, a =#+NAME= or a heading, as above. |
103
104** Attachment links
105
106An =attachment:= link names a file in the attachment folder of the entry that holds
107the link (see [[file:04-outlines.org][Outlines]] for the attachment commands). Relative folders are resolved
108against the folder of the file that holds the link:
109
1101. When the entry has a =DIR= property, or the older =ATTACH_DIR=, that folder.
1112. Otherwise, for an entry with an =ID=, the first of these folders that exists:
112   =org-attach-id-dir= (=data/=) followed by the ID's first two characters, =/= and
113   the rest of the ID; followed by its first six characters, =/= and the rest;
114   =__/=, the ID's first character, =/= and the whole ID. When =org-attach-id-dir= is
115   something else, the same folders under =data/= are found too.
116
117=org-attach-use-inheritance= decides whether =DIR= and =ID= may come from an ancestor.
118
119When the folder does not exist, the path is relative to the file's own folder. The file then opens as a =file:= link would, and
120a search option after =::= works the same way.
121
122** id links
123
124=id:= links are resolved through the index, so the target heading must be in a file
125under one of your sidebar folders. An =ID= in the property drawer before a file's first
126heading names the file, as org-roam's file nodes do, and the link opens the file. A link
127to an ID that isn't indexed shows =No heading has the ID= followed by the ID.
128
129** Timestamps
130
131=C-c C-o= (Mac =⌃⌘O=) or =⌘=-click on a timestamp opens the agenda on that day, as
132=org-follow-timestamp-link= does. On a date range such as
133=<2026-10-05 Mon>--<2026-10-09 Fri>=, the agenda shows the whole span. See
134[[file:07-agenda.org][Agenda]].
135
136* Inserting and editing links
137
138=org-insert-link= asks for a link and a description in the echo area.
139
140| Preset | Key                          |
141|--------+------------------------------|
142| Emacs  | =C-c C-l=                    |
143| Mac    | =⌘K=                         |
144| Doom   | =SPC m l l=, or =C-c C-l=    |
145
146The first prompt reads =Insert link:=, or =Insert link (default …):= when you have
147stored links. It completes from:
148
149- your stored links, most recent first, and their descriptions;
150- the link abbreviations defined in the file (see /Link abbreviations/);
151- the link types =attachment=, =id=, =eww=, =rmail=, =mhe=, =irc=, =info=, =gnus=, =docview=,
152  =bibtex=, =bbdb=, =w3m=, =doi=, =file+sys=, =file+emacs=, =shell=, =news=, =mailto=,
153  =https=, =http=, =ftp=, =shortdoc=, =help=, =file= and =elisp=, each followed by =:=.
154
155Pressing Return on an empty answer inserts the most recent stored link. Choosing a
156description inserts the link it belongs to. If you choose a bare type such as =https:=,
157a second prompt, =Link (no completion support):=, asks for the rest.
158
159The next prompt, =Description:=, offers the stored link's description, or the
160selected text if you selected some before running the command. An empty description
161inserts a link without one. With text selected, the link replaces the selection.
162
163When the caret is on an existing link, the same command edits it: the =Link:= prompt
164starts with the current target and =Description:= with the current description.
165
166A stored link that you insert is removed from the stored list, as with
167=org-link-keep-stored-after-insertion= set to nil.
168
169** File paths in inserted links
170
171When the inserted link is a =file:= link, orgstar rewrites it as
172=org-link-make-string-for-buffer= does:
173
174- A link to a heading or target in the file you are editing loses its =file:= part
175  and keeps only the search, for example =[[*Ideas]]=.
176- A path under the current file's folder becomes relative to it.
177- Any other path is written with =~= for your home folder.
178
179** Completion while typing
180
181You can also type a link by hand. With the caret right after =[[=, completion at point
182offers =attachment:=, =doi:=, =file:=, =http:=, =https:=, =id:= and =mailto:=, plus
183the file's link abbreviations. After =[[*=, it offers the headings of the current file.
184Completion at point is =C-M-i= in the Emacs preset and =C-SPC= in Doom's insert state;
185see [[file:02-the-editor.org][The editor]].
186
187* Storing links
188
189=org-store-link= remembers a link to where the caret is, for a later Insert Link.
190
191| Preset | Key                                   |
192|--------+---------------------------------------|
193| Emacs  | =C-c l=                               |
194| Mac    | =⌃⌘L=                                 |
195| Doom   | =SPC m l s= or =SPC n l=              |
196
197The stored link is a =file:= link to the current file, written with =~= for your home
198folder, followed by a search option chosen as Org does with
199=org-link-context-for-files= on:
200
2011. If the caret touches a =<<target>>= on its line, the link points at the target.
2022. Otherwise, if text is selected, the link searches for that text.
2033. Otherwise, if the caret is in an element with a =#+NAME=, the link uses the name.
2044. Otherwise, inside a heading's entry, the link uses =#custom-id= if the heading has a
205   =CUSTOM_ID= property, and =*Title= if not. The title becomes the description.
2065. Before the first heading, the link searches for the text of the current line.
207
208The echo area shows =Stored:= and the description or link. Storing the same link again
209moves it to the front of the list. Stored links last until you quit orgstar; they
210aren't saved between sessions, as in Emacs.
211
212* IDs
213
214Org identifies headings across files with an =ID= property. Two commands manage it.
215
216| Command               | Org function                          | Keys                              |
217|-----------------------+---------------------------------------+-----------------------------------|
218| Org ▸ Create ID       | =org-id-get-create=                   | No default key                    |
219| Org ▸ Store ID Link   | =org-id-get-create= + =org-id-store-link= | Doom =SPC m l i=; no key in Emacs or Mac |
220
221Create ID gives the heading at the caret an =ID= property if it doesn't have one. The
222ID is a new UUID in lower case, for example =6a3c2f9e-…=, as =org-id-uuid= makes them. Before the first heading,
223the property goes into the file-level property drawer.
224
225Store ID Link does the same, then stores an =id:= link to the heading with its title
226as the description. Before the first heading, the description is the =#+TITLE=, or
227the file name. If the caret is on a target or named element inside the entry, the
228link carries that search, as =id:…::search=, which mirrors =org-id-link-use-context=.
229
230=CUSTOM_ID= is a property you set yourself, with the property commands in
231[[file:04-outlines.org][Outlines]]. Link to it with =[[#name]]= in the same file or
232=[[file:other.org::#name]]= from another. Store Link uses it when the heading has one.
233
234* Targets and radio targets
235
236=<<target>>= marks a place in the text that a link with the same words reaches:
237=[[target]]=. Store Link with the caret on a target stores a link to it.
238
239=<<<radio target>>>= makes every other occurrence of its words in the file a link,
240matched case-insensitively and between non-word characters. Radio links are
241highlighted as links and exported as links to the target (see
242[[file:12-export.org][Export]]). Following one moves to the radio target.
243
244* Link abbreviations
245
246A =#+LINK:= line defines an abbreviation, as =org-link-abbrev-alist-local= does:
247
248#+BEGIN_SRC org
249,#+LINK: gh https://github.com/%s
250,#+LINK: search https://duckduckgo.com/?q=%h
251,#+LINK: wiki https://en.wikipedia.org/wiki/
252
253[[gh:orgmode/org-mode]]   → https://github.com/orgmode/org-mode
254[[search:org tables]]     → https://duckduckgo.com/?q=org%20tables
255[[wiki:Org-mode]]         → https://en.wikipedia.org/wiki/Org-mode
256#+END_SRC
257
258In the template, =%s= is replaced by the text after the colon, =%h= by the same text
259percent-encoded, and a template with neither has the text appended. Function
260templates (=%(…)=) are not supported. Abbreviations from a =#+SETUPFILE= count too.
261When a key is defined twice, the first definition wins.
262
263* The backlinks pane
264
265View ▸ Show or Hide Backlinks shows a pane beside the editor of an org file. It has
266two sections:
267
268- *Links to* the heading at the caret, named after that heading.
269- *Links to this file*.
270
271Each row shows the linking heading and its file name; a link in the text before a
272file's first heading is listed under the file's name. Click a row to open it. The
273pane is shown by default and updates as you move the caret and edit.
274
275The pane looks at every org file in your sidebar folders, including unsaved changes
276in open buffers. A link counts when following it would lead to the heading or the
277file:
278
279- =id:= links to the heading's =ID=, or to the file's own =ID= for the file section;
280- =file:= links and plain paths (=./=, =../=, =/=, =~/=) to the file, with no search
281  option for the file section, or with =::*Title=, =::#custom-id= or =::Title= for a
282  heading;
283- within the same file, =[[*Title]]=, =[[#custom-id]]= and =[[Title]]=.
284
285Links to targets, names and line numbers are not counted. A heading's links to itself
286are left out.
287
288* Nodes and daily notes
289
290orgstar works with notes kept the org-roam way: headings and files with an =ID= are
291/nodes/, linked with =id:= links, and a daily note is a file a day. It reads them from
292the index, without org-roam's database.
293
294| Command | Emacs | Doom | What it does |
295|-+-+-+-|
296| Find Node… | =C-c n f= | =SPC n r f= | Asks for a node by title and opens it (=org-roam-node-find=). |
297| Insert Node Link… | =C-c n i= | =SPC n r i= | Asks for a node and inserts =[[id:…][Title]]=; with a selection, the selection is the description (=org-roam-node-insert=). |
298| Go to Today's, Yesterday's, Tomorrow's Daily Note | =C-c n d d=, =y=, =t= | =SPC n r d t=, =y=, =m= | Opens the day's note, making it if missing (=org-roam-dailies-goto-today= and the others). |
299| Go to Daily Note for Date… | =C-c n d c= | =SPC n r d d= | Asks for a date, then opens its note. |
300| Capture to Today's Daily Note (and Yesterday's, Tomorrow's, for Date…) | =C-c n j=, =C-c n d n=, =C-c n d v= | =SPC n r d n=, =T=, =Y=, =M=, =D= | Files the entry template at the end of the day's note and opens it at =%?= (=org-roam-dailies-capture-today= and the others). |
301| Next Daily Note, Previous Daily Note | =C-c n d f=, =b= | =SPC n r d f=, =b= | From a daily note, opens the next or previous one there is (=org-roam-dailies-goto-next-note=). |
302
303The keys are the ones org-roam's manual suggests for Emacs and Doom's. Titles that
304repeat show their file's name. A file node's title is its =#+TITLE=, or its name.
305
306Daily notes are in =org-roam-dailies-directory= (=daily/=) under =org-roam-directory=,
307which is the first sidebar folder unless set. A new note is named and started as
308org-roam's default daily template does it, with an =ID= like every new org-roam file:
309
310#+BEGIN_SRC org
311,:PROPERTIES:
312,:ID:       5f0c1e2a-…
313,:END:
314,#+title: 2026-10-11
315#+END_SRC
316
317=org-roam-dailies-file= (="%<%Y-%m-%d>.org"=), =org-roam-dailies-head=
318(="#+title: %<%Y-%m-%d>\n"=) and =org-roam-dailies-entry= (="* %?"=) change the file name,
319what a new note starts with, and what capturing adds; =%<…>= formats the note's date as
320=format-time-string= does. The entry is an org-capture template; its date escapes
321(=%t=, =%U= and the like) use the note's day. Import from Emacs reads them from the first of
322=org-roam-dailies-capture-templates=. See [[file:13-configuration.org][Configuration]].
323
324* Inline images
325
326=org-toggle-inline-images= shows image links as images.
327
328| Preset | Key                                          |
329|--------+----------------------------------------------|
330| Emacs  | =C-c C-x C-v=                                |
331| Mac    | Org ▸ Show or Hide Inline Images             |
332| Doom   | =C-c C-x C-v=                                |
333
334The echo area reports how many images are shown, or that inline display is off.
335
336A line shows an image when it holds nothing but a bracket link, without a description,
337to a file ending in =.png=, =.jpg=, =.jpeg=, =.gif=, =.svg=, =.webp=, =.tif=, =.tiff=,
338=.bmp=, =.heic= or =.avif= (in any case):
339
340#+BEGIN_SRC org
341[[file:images/diagram.png]]
342[[./photo.jpg]]
343#+END_SRC
344
345Relative paths are resolved against the file's folder. =attachment:= links are not
346shown as images. The link text is hidden while the image is shown, except on the line
347that holds the caret.
348
349** Remote images
350
351Images at =http= and =https= links show as =org-display-remote-inline-images= in
352=config.toml= says:
353
354| Value      | Remote images                                                                |
355|------------+------------------------------------------------------------------------------|
356| =skip=     | Not shown; the default                                                       |
357| =download= | Fetched the first time they're shown, and kept until orgstar quits           |
358| =cache=    | Fetched once and kept on disk, in the app's cache folder, for later launches |
359
360#+BEGIN_SRC org
361[[https://example.com/chart.png]]
362#+END_SRC
363
364An image is fetched in the background; the link shows as text until it arrives. A link
365that can't be fetched stays text, and isn't tried again until orgstar starts again. This
366applies to the editor on the Mac and iOS and to the iOS reader. Emacs's =download=
367fetches the image each time it's displayed; orgstar keeps it for the session instead.
368
369** Sizing
370
371An image is drawn at its own width, up to the width of the text area. To set a width,
372put =#+ATTR_ORG: :width= with a number of points among the keywords above the link:
373
374#+BEGIN_SRC org
375,#+CAPTION: Network layout
376,#+ATTR_ORG: :width 300
377[[file:images/network.png]]
378#+END_SRC
379
380The height follows the image's proportions. =#+ATTR_HTML= and other exporters'
381attributes don't affect the editor.
382
383** Showing images when a file opens
384
385The config key =org-startup-with-inline-images= (default =false=) shows images in
386every file when it opens. In a file, =#+STARTUP: inlineimages= or
387=#+STARTUP: noinlineimages= overrides it.
388
389* org-protocol store-link
390
391orgstar handles =org-protocol://store-link= URLs, in the new form
392~org-protocol://store-link?url=…&title=…~ and the old form
393=org-protocol://store-link:/URL/TITLE=. The URL is added to your stored links with
394the title as its description, and is also copied to the clipboard. Insert it with
395Insert Link. Setting up a browser bookmarklet, and =org-protocol://capture=, are in
396[[file:08-capture.org][Capture]].
397
398* On iOS
399
400The iOS app follows links: tap a link in the reader. Org files open in the app, and
401web, mail and other files go to the system. The iOS editor shows inline images as the
402Mac does; the reader doesn't. In the editor, Store Link, Store ID Link and Insert Link…
403are in Commands, and on a hardware keyboard the Emacs keys run them; they work as
404described above, and stored links last until the app quits. =org-protocol://store-link=
405links opened on the device are stored and copied too. More ▸ Backlinks lists the same
406links as the Mac's backlinks pane, for the heading at the caret and the file. See
407[[file:14-ios.org][iOS]].
408
409* Code references
410
411A label at the end of a line in a src or example block, =(ref:name)= by default, is a code reference, and =[[(name)]]= links to it. Following the link moves to the label. A block's =-l "<<%s>>"= switch changes the label's form for that block; =%s= is the name.
412
413In export, the label is taken off the line. A block with =-n= numbers its lines from 1, or =-n 10= from 10; =+n= goes on from the numbers of the blocks before it. =-r= leaves the label out of the exported line, and then the link shows the line's number instead of the name; =-k= with =-n= keeps the label while the link still shows the number. A link's description may contain =%s= for the name or number: =[[(call)][line %s]]=. In HTML, the line with the label is the link's target, =coderef-name=.
414
415A regexp link, or a =file:…::/regexp/= search, exports as its description, or its text when it has none.
416