1

Every time I publish html files in org-mode, I clutter up my directory with them.

Is there a way to automatically export html files to a specific directory?

I've tried this solution: https://stackoverflow.com/questions/9559753/emacs-org-mode-export-to-another-directory#9560534

However there is no org-export-publishing-directory in my emacs. I'm not sure why.

Thanks for any help.

1

A long time ago there was an export backend for org that defined org-export-publishing-directory, but it disappeared when the export code was rewritten. It turns out that the export functions can still do it with a little help. Here's how I set things up by advising an org function:

;; Add advice to let me set a different directory for the exported
;; files. Usually I do this with a directory-local variable for a
;; project, like this:
;; ((org-mode . ((my/org-export-dir "export-dir"))))

(defun my/set-org-export-directory (orig-fun extension
                                    &optional subtreep pub-dir)
  "Advice function to set export directory for `org-export-output-file-name'.
Set `my/org-export-dir' to specify the desired export directory."
  (let ((pub-dir (or pub-dir
                     (and (boundp 'my/org-export-dir)
                          my/org-export-dir))))
    (apply orig-fun extension subtreep pub-dir)))

(advice-add 'org-export-output-file-name
            :around #'my/set-org-export-directory)

Of course, this is fragile with respect to changes in the org code!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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