I am trying to set org-html-link-org-files-as-html to nil for a single org-file (but have the value equal t for all other org files). This is a variable defined in ox-html.

(defcustom org-html-link-org-files-as-html t
  "Non-nil means make file links to `file.org' point to `file.html'.
When `org-mode' is exporting an `org-mode' file to HTML, links to
non-html files are directly put into a href tag in HTML.
However, links to other Org-mode files (recognized by the
extension `.org.) should become links to the corresponding html
file, assuming that the linked `org-mode' file will also be
converted to HTML.
When nil, the links still point to the plain `.org' file."
  :group 'org-export-html
:type 'boolean)

I have tried setting

#+OPTIONS: org-html-link-org-files-as-html:nil

and setting

# -*- org-html-link-org-files-as-html:nil; -*-

at the top of the file. Neither work - only works when I set in emacs-lisp

(setq org-html-link-org-files-as-html nil)

but then this applies to all org files. Can I set it for a single org-file?

  • 1
    Try: #+BIND: org-html-link-org-files-as-html:nil. – NickD Jan 29 at 14:22
  • @NickD thanks - org-export-allow-bind-keywords also needs to be set to non-nil but then it works - can you please write it as an answer and then I can mark it as correct. – hatmatrix Jan 30 at 3:54
  • Done - expanded it a bit and added a ref to the manual. – NickD Jan 30 at 15:13

For variables that cannot be set through the #+OPTIONS keyword, the #+BIND keyword mechanism can be used. Adding

#+BIND: org-html-link-org-files-as-html:nil

to the top of your file would be equivalent to your #+OPTIONS line if the option existed. #+BIND was introduced as a mechanism to set export options without having to set up options explicitly and a priori, as #+OPTIONS requires (basically, Carsten Dominik, the creator of org-mode, got tired of having to add more options as user requests were coming in and provided an extensible mechanism). Not everything can be done with #+BIND but it is perfect for this use.

The manual says:

If org-export-allow-bind-keywords is non-nil, Emacs variables can become buffer-local during export by using the ‘BIND’ keyword. Its syntax is #+BIND: variable value. This is particularly useful for in-buffer settings that cannot be changed using keywords.

See also a related SO post of mine on this topic.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.