In the org-mode documentation regarding export settings, it describes arch as follows.

Configure export of archived trees. Can be set to headline to only process the headline, skipping its contents (org-export-with-archived-trees).

That's almost what I want, but it skips all the contents, including the subheadings. I want those subheadings too (without their contents). Take this example:

#+OPTIONS: arch:headline

* I want to see this :ARCHIVE:
But not this.
** and also this.
And definitely not this.

If I export this file, I want to see this is the only thing that comes through. But I was expecting/hoping and also this to be exported underneath it as well.

How do I make that happen? I tried adding an extra :ARCHIVE: tag to the second level heading, but that does nothing.

  • This is kind of the reverse of a similar question that I asked: emacs.stackexchange.com/questions/9492/… I imagine a very similar answer would also work here, but my elisp skills are close to nil.
    – Brian Z
    Commented Mar 20, 2015 at 13:54

1 Answer 1


You're right, the code that I posted over there can be modified to achieve the behavior you want:

(defun org-remove-contents (backend)
  "Remove contents of headlines with :ARCHIVE: tag."
  (org-map-entries (lambda () 
                     (let ((beg (point)))
                       (outline-next-visible-heading 1)
                       (delete-region beg (point))))
                   "ARCHIVE" tree))

(add-hook 'org-export-before-processing-hook #'org-remove-contents)

Note that you'll need to set arch to t in your per-file #+OPTIONS for this to work:

#+OPTIONS: arch:t
  • This is a problem for LaTeX which doesn't like empty sections and subsections (tex.stackexchange.com/questions/234321/…), but I can work around it. Thanks!
    – Brian Z
    Commented Mar 21, 2015 at 16:30
  • @BrianZ Huh. LaTeX export works without a hitch on my machine (with #+OPTIONS: arch:t and both headlines tagged with :ARCHIVE:)...
    – itsjeyd
    Commented Mar 22, 2015 at 8:21
  • Try it with something bigger, so that the output is more than one page. If you export that to a PDF via LaTeX, does it still work for you?
    – Brian Z
    Commented Mar 22, 2015 at 9:02
  • I got 'org-remove-contents: Symbol’s value as variable is void: tree'. How I can fix this?
    – slk500
    Commented Apr 17, 2019 at 11:50

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.