Skip to main content

13.9.7 Links in HTML export

The HTML export back-end transforms Org’s internal links (see Internal Links) to equivalent HTML links in the output. The back-end similarly handles Org’s automatic links created by radio targets (see Radio Targets) similarly. For Org links to external files, the back-end transforms the links to relative paths.

For Org links to other ‘.org’ files, the back-end automatically changes the file extension to ‘.html’ and makes file paths relative. If the ‘.org’ files have an equivalent ‘.html’ version at the same location, then the converted links should work without any further manual intervention. However, to disable this automatic path translation, set org-html-link-org-files-as-html to nil. When disabled, the HTML export back-end substitutes the ID-based links in the HTML output. For more about linking files when publishing to a directory, see Publishing links.

Org files can also have special directives to the HTML export back-end. For example, by using ‘#+ATTR_HTML’ lines to specify new format attributes to <a> or <img> tags. This example shows changing the link’s title and style:

#+ATTR_HTML: :title The Org mode homepage :style color:red;