My org file is named README.org and I want to export to Markdown into a file named README. Every time I run the export it writes to README.md. Here is my org file:


* Test export

I'm using the EXPORT_FILE_NAME property based on this link: http://orgmode.org/manual/Export-settings.html#index-property_002c-EXPORT_005fFILE_005fNAME-1617 but it doesn't seem to do anything.

  • 2
    Your link says "In all cases, only the base name of the file is retained, and a back-end specific extension is added. " That makes it sound like you'll always get the ".md".
    – erikstokes
    Mar 30, 2015 at 0:50
  • 1
    You're completely right. Looks like the extension is not configurable. Feature request for org-mode?
    – Conor
    Mar 31, 2015 at 2:27

5 Answers 5


According to the cited manual page, EXPORT_FILE_NAME applies only for subtree export.

Whole file export will take its name from the buffer file name.

If you only have 1 level-1 headline, you may add this property to a drawer inside the first heading, and always export as subtree from inside this top-level heading to get your desired file name.


For more recent versions of org-mode a new export setting was added, #+EXPORT_FILE_NAME:, which will set the file name when file is exported.

  • For example:


The setting can be overwritten inside the properties drawer under a heading.

  • For example:

    * Chapter 2
    :EXPORT_FILE_NAME: chapter2

This code was tested using:
emacs version: GNU Emacs 25.2.1 (x86_64-unknown-cygwin, GTK+ Version 3.22.10)
Org mode version: 9.1.2


An easy workaround is to add this at the bottom of the source Org file:

# Local Variables:
# after-save-hook: (lambda nil (when (org-html-export-to-html) (rename-file "README.html" "index.html" t)))
# End:

In this example, assuming the source file is named README.org, it will automatically export the file to HTML and then rename it to index.html.


You can use the function org-export-to-file

This will let you specify the file you want to save to and the back-end for the export.

(org-export-to-file 'html "README.html" )

I was inspired by user3871's amazing idea to go a bit further, including configuring a safety exception so you don't get prompted to allow the code to run when opening the file.

I append this to the file to generate an HTML version of the same file on every save:

# Local Variables:
# after-save-hook: (lambda nil (org-export-to-file 'html (format "dest_dir/%s.html" (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))))
# End:

To make it stop prompting me, I did this rudimentary safe-variable exception:

;; not perfectly secure, just checks for lambdas that call org-export-to-file as the first form.
(defun my-validate-after-save-hook (form)
  (and (eq (nth 0 form) 'lambda)
       (eq (car (nth 2 form)) 'org-export-to-file)))
(put 'after-save-hook 'safe-local-variable 'my-validate-after-save-hook)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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