reddit / emacs

Linking to headlines from other org files

deafpolygon · 2022-12-14 10:22
What's a strategy for linking to headlines in such a way that the link won't break (assuming.. you don't move the file)? I've noticed that changing the headline (i.e. date, tags) will break the link and it will try to make a new headline (prompting do you want to create...) in the file instead. Do you link between your org files?
akirakom · 2022-12-14 10:25
Set `org-id-link-to-org-use-id` to t and link extensively between files.
IceOleg · 2022-12-14 10:25
ID links. Use `org-id-get-create` to give the heading an ID. I don't have a good suggestion for how to conveniently create the link, between Doom and org-roam I get the functionality given to me.
deafpolygon · 2022-12-14 10:43
That works great. How does org keep track of the ID?
akirakom · 2022-12-14 10:51
There is a cache (`org-id-locations-file`), and if the cache misses, org scans agenda files.
deafpolygon · 2022-12-14 10:55
That works for me, I think. It appears robust enough.
schmooser · 2022-12-14 18:41
Try org-store-link, then C-c C-l to insert last stored link. The downside is that links get broken if target heading gets renamed.
shryzr · 2022-12-15 02:56
I think org probably scans the org directory, because links outside agenda files work fine.
akirakom · 2022-12-15 03:45
There are some other scanning targets in addition to agenda files. It doesn't scan `org-directory` itself but open org buffers. See `org-id-update-id-locations`.
shryzr · 2022-12-15 04:31
Yeah. I see now. I sync my org id locations file across machines in git and maintain the same path anyway, so it pulls id’s from the files listed there and links work. Wonder how scalable it is.