In org-mode, I can exclude a code blocks from HTML export with something like this:

#+header: :eval (eval (if (string= org-export-current-backend "html") "no" "yes")))
#+begin_src R

How can I achieve the same for a heading and its contents? Something like a conditional noexport tag. I have tried to use similar elisp code in the PROPERTY drawer but this and several variations did not work:

* Section
:EXPORT: (eval (if (string= org-export-current-backend "html") "no" "yes")))

I have also tried to set a TAGS property to noexport or :noexport:


1 Answer 1


I found an answer based on dalanicolai's comment, which led me here. I tag the headings that I don't want to export to, say, latex with noexport_latex and I also define this hook to add to org-export-before-parsing-hook:

(defun exclude-from-latex-export-hook (backend)
  (setq org-export-exclude-tags (remove "noexport_latex" org-export-exclude-tags))
  (if (string= backend "latex")
  (push "noexport_latex" org-export-exclude-tags)))

This uses the standard selective export mechanism but modifies the list of excluded tags on the fly depending on the export backend.

  • 1
    Ah great, I guess you peeked at @NickD's answer then also. I did not have much time to look into it, but I remembered that question/answer was very much related. Nice that it 'worked out well'! And thanks for sharing the solution, of course... Mar 24 at 3:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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