In org-mode, if I do org-export-dispatch, then choose Export to HTML, I can then choose As HTML file and open. Four keystrokes though.

I'd like to reduce this to a single keybinding. However, I don't see a function to export to HTML file AND open the file in a browser. I see only the function org-html-export-to-html, which does not open the file.

How can I export to HTML and open the file with a single keybinding?

  • 1
    As you say, C-c C-e h o the first time C-u C-c C-e the next time. You can see the underlying Emacs Lisp by searing for :menu-entry in ox-html.el.
    – rasmus
    Commented Sep 14, 2017 at 16:25

1 Answer 1


I don't think there's a direct function for this, but you could achieve what you want using org-export-to-file, the last argument of which is a "post-processing" step:


The post-processing step is handed the path to your new file; you could use something as straight-forward as find-file:

(defun org-html-export-to-html-and-open 
  (&optional async subtreep visible-only body-only ext-plist)
  (let ((outfile (org-export-output-file-name ".html" subtreep)))
    (org-export-to-file 'html outfile async subtreep visible-only body-only ext-plist #'find-file)))

(define-key org-mode-map (kbd "whatever you fancy") 'org-html-export-to-html-and-open)
  • Thanks! This opens the .html file in Emacs. But the desired behavior is to launch it in a browser, which is what happens if I do org-export-dispatch, then choose Export to HTML, then choose As HTML file and open. Commented Sep 13, 2017 at 19:54
  • 1
    Ah! I misunderstood. This part, then, will be somewhat context dependent. My approach would be to shell out to a command which will open the file (since you have the path on hand) -- on OSX/macOS you could use the open utility, for instance. Does that make sense?
    – Gastove
    Commented Sep 14, 2017 at 3:55
  • what would that look like in the function? Commented Sep 14, 2017 at 4:35

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.