I'm exporting an org file to HTML that will live at http://example.com/foo/bar.html and also at http://another.url/a/b/c.html. I'd like to write some org syntax that exports links to other files on the same server.

Case 1. I want to link to another file in the same directory. How do I get output <a href="data.txt">lore</a>?

  • [[data.txt][lore]] --> error "Unable to resolve link"
  • [[./data.txt][lore]] --> <a href="./data.txt">lore</a> - good enough

Case 2. I want to link to a file in the root directory. How do I get output <a href="/robots.txt">skynet</a>?

  • [[/robots.txt][skynet]] --> <a href="file:///robots.txt">skynet</a>, not what I want
  • [[../../robots.txt][skynet]] --> <a href="../../robots.txt">skynet</a> - works only if I know how many levels up

Is there a direct way to output data.txt or /robots.txt as the link without getting file:// prepended, and without having to use ./ and ../ as workarounds?

I see a different workaround on this question but the function mentioned there, org-add-link-type, is marked Obsolete in org 9.0, and it's not obvious to me how to use org-link-set-parameters for this.

  • Maybe a duplicate. – NickD Mar 8 '19 at 4:29
  • @NickD No that is not a duplicate. org-link-file-path-type only occurs in org-insert-link which has little to do with the export of orgmode. – Tobias Mar 8 '19 at 8:31
  • I've added the version with org-link-set-parameters in the answer to the other question. That makes this question to a duplicate of the other one. – Tobias Mar 8 '19 at 9:06
  • @Tobias: thank you! – amitp Mar 9 '19 at 1:59

Browse other questions tagged or ask your own question.