I am exporting my org-mode file via org-export-as-html, but when I check the file type via file my/file.html, it is XML. I notice the first three lines in my HTML exported file is the following:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

which is a reasonable explanation. If I manually re-order these lines to the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<?xml version="1.0" encoding="iso-8859-1"?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

then the file is correctly identified as HTML. How do I correct this issue in my export function? I checked the org-mode docs here but they seem out of date:


because I do not have their listed commands, but org-export-to-html and org-export-as-html-to-buffer.

Any suggestions would be very helpful.

BTW I am on Emacs 24.3 with Ubuntu 14.04. Here are the first few lines of my org file:

Flatsheet Project Mgmt -*- mode: org -*-
#+INFOJS_OPT: view:overview toc:true

* project stuff...
* more project stuff...


I found this link potentially helpful, but their suggestion is not working:


There is a section called 16.8.2 Export HTML without XML header, but their solution below does not work for me:

(setq org-html-xml-declaration (quote (("html" . "")
                                       ("was-html" . "<?xml version=\"1.0\" encoding=\"%s\"?>")
                                       ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))))
  • 2
    when you do org-version what do you get, and did you try setting the equivalent of org-html-doctype?
    – pjammer
    Commented Feb 25, 2015 at 12:00
  • XHTML is an XML document. Why do care what file says?
    – user2005
    Commented Feb 25, 2015 at 13:20
  • @rekado Because my static "web server" (aka Amazon S3) was detecting the file at XML, thus it was not loading the javascript/css properly.
    – modulitos
    Commented Feb 25, 2015 at 13:46
  • @pjammer you were right, I did not update my org package, which is apparently under heavy development. I was at 7.9x, but I upgrade to the latest stable and it works! It looks like they redid the exporter, which should make everything smoother from here on out :-)
    – modulitos
    Commented Feb 25, 2015 at 13:49
  • In this case you may answer your question yourself.
    – user2005
    Commented Feb 25, 2015 at 14:07

2 Answers 2


This was resolved by upgrading to the latest version of org-mode, detailed here

I did it through the ELPA package manager, with marmalade packages, to upgrade org-mode from 7.9 to 8.2. Org-mode seems to be under heavy development, and it has a new export engine, which was probably the cause of my error.

When re-installing a package, just be sure to delete any existing org package directory under .emacs/elpa/org... and restart emacs with emacs -q and THEN install the latest package to avoid conflicts! YMMV but it worked for me.

After that, it exported fine, with a DOCTYPE html declaration at the top of the file. Now the file is recognized as HTML instead of XML.

  • Here's. more information on what's new on Org 8.0 and how it may affect your existing org-mode configuration in your init file. Commented Feb 26, 2015 at 12:13
  • An alternative solution would have been to use pandoc to convert from org-mode to html 5.
    – Ben
    Commented Oct 8, 2015 at 22:50

XML export is still the default as of org 9.4, but you can override in several ways. For example, I export as html5 by putting this in my init file:

(setq org-html-doctype "html5")

You can also set this per-file with this at the top:


Using either of these methods generates this html:

<!DOCTYPE html>
<html lang="en">

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.