Endless Parentheses

Concise ramblings on Emacs productivity.

Markdown style link IDs in org-mode

The Power of Org-links post series

Link handling and exporting is one of the most versatile aspects of org-mode. Did you know you can make org-mode understand Markdown style link IDs?

You should already know org-links can do absolutely anything, but it takes a little creativity to know how to apply that. Here's the question by Kaushal that prompted this over at Emacs.StackExchange.

At times, I need to use the same link at multiple places in a long document. For those cases it would be useful to have link IDs like in markdown.

This is [an example][some-id] reference-style link. 

Then, anywhere in the document, you define your link label like this, on a line by itself:

 [some-id]: http://example.com/

The solution I came up with defines three different functions, so I’ll let you follow the link instead of clogging up this blog post. The result is that you can define link IDs like this anywhere in your document (probably the top or the bottom).

#+LINK-ID: wiki http://www.emacswiki.org

And then you can use that URL in links throughout the document by writing them like this.

Here is a [[lid:wiki][wiki link]], and here 
is [[lid:wiki][another one]].

Tags: org-mode, init.el, emacs

Say thanks on Gratipay
comments powered by Disqus