I'm rewriting my personal home page as an org-file that I export to HTML. In this HTML document, I'd like to include the content of some pregenerated HTML fragments stored in other files (my list of publications as generated by bibtex2html).

Here is an example document:

* My personal home page
** Articles
[insert HTML file with list of articles here]

** Posters
[insert HTML file with list of posters here]

I tried using #+INCLUDE: but that escapes all HTML and hence shows the HTML source in the resulting web page not the rendered HTML fragment.

I also tried the following

#+INCLUDE: "file.html"

but the #+INCLUDE directive is not interpreted inside the HTML block.

It seems like there should be an easy way to achieve this but I can't seem to find it.

  • First I would look into defining an appropriate :html-preamble or a :html-postamble, maybe using a #+SETUPFILE: to invoke it. Another approach would be to add a org-export-html-final-hook, possibly with help from auto-insert.
    – Brian Z
    Commented Mar 18, 2015 at 6:31
  • 1
    Thanks @BrianZ for these suggestions. Unfortunately, :html-preamble and :html-postamble won't work because I need to insert the HTML fragments in the middle of the file not at the beginning and end. org-export-html-final-hook is mentioned in a ChangeLog but I can't find its definition anywhere in source. apropos also doesn't know it. I'll post a feature request for a verbatim flag for #+INCLUDE.
    – tmalsburg
    Commented Mar 18, 2015 at 18:00

2 Answers 2


Cf. the second paragraph in the Org manual on #+INCLUDE you can archive what you want using (Org v9 syntax)

#+INCLUDE: "file.html" export html

For Org v8 you would write #+INCLUDE: "file.html" html.

This inserts is a block and requires org-mode v8.3 or higher.

11.4 Include files

During export, you can include the content of another file. For example, to include your ‘.emacs’ file, you could use:

 #+INCLUDE: "~/.emacs" src emacs-lisp

The first parameter names the the file to include. The optional second and third parameter specify the markup (i.e., ‘example’ or ‘src’), and, if the markup is ‘src’, the language for formatting the contents.

  • 1
    As I said in the original question, this doesn't work. It escapes all HTML such that I see the HTML source but not the rendered version of the HTML in the output file.
    – tmalsburg
    Commented Mar 18, 2015 at 17:42
  • Ok, it works but only in org mode version 8.3 (unstable). Perhaps you could add that crucial piece of information to the solution. Thank you.
    – tmalsburg
    Commented Mar 18, 2015 at 19:37
  • Same prob with latest org from github 8.3.4, I try to include html code from htmlcommentbox.com to enable comments.
    – barrios
    Commented Mar 14, 2016 at 13:46

I'm using org-mode 8.2.10

Although I was expecting #+INCLUDE: "path" html to work, it was formatting the file contents in <p> tags.

To work around this problem, I used an sh code block:

#+BEGIN_SRC sh :exports results :results value html
/bin/cat ~/path/to/file.html

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.