I have an org document with scattered with source blocks that I'd like excluded when I export the file to html.

Is there a variable or option I can set which will ignore the src blocks?

I have tried using the noexport as shown below but the code still appears in the resultant html.

#+BEGIN_SRC json :noexport:
{ ... }


  • 5
    :exports none should do it.
    – mutbuerger
    Oct 30, 2015 at 9:21
  • 2
    @mutbuerger: Could you maybe make an answer out of that? It really is the preferred solution. It can be combined with header-argument defaults, so that all source blocks' export can be controlled with only one setting, and no emacs lisp code.
    – timor
    Jun 23, 2016 at 9:16

2 Answers 2


A solution that doesn't depend on org-export-filter-src-block-functions and gives you more flexibility is using the :exports header argument (see (info "(org) Exporting code blocks")). Setting the argument to :exports none results in neither the code block nor its results being exported.

If you prefer a backend specific rule, you may use a conditional as the argument:

#+begin_src elisp :exports (when (eq org-export-current-backend 'html) "none")
(+ 1 2)
  • While the accepted solution works if all src blocks in an org file need to be excluded, this solution works if only certain src blocks are to be excluded. This is more customizable without creating additional functions.
    – Emacs User
    Jun 23, 2016 at 11:35
  • Neat! Is this use of lisp code as header argument value documented?
    – JeanPierre
    Dec 26, 2016 at 9:19
  • I'm not sure, but a look at org-babel-merge-params makes this pretty obvious. For the :results there is even an explicit (if (stringp value) value (eval value t)) ... for whatever reason.
    – mutbuerger
    Dec 26, 2016 at 10:11

Based on section 12.15 of org documentation:

(defun my-html-filter-src-blocks (text backend info)
  "Remove source blocks from html export."
  (when (org-export-derived-backend-p backend 'html)
    "[removed source block]"))

(add-to-list 'org-export-filter-src-block-functions

Replace "[removed source block]" with an empty string of course!

  • This works globally too which is great. Thanks!
    – Grassdog
    Oct 30, 2015 at 14:40

Your Answer

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

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