15

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:

#+PROPERTY: EXPORT_FILE_NAME thing

* 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 '15 at 0:50
  • 1
    You're completely right. Looks like the extension is not configurable. Feature request for org-mode? – Conor Mar 31 '15 at 2:27
12

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.

8

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:

    #+EXPORT_FILE_NAME: README.txt
    

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

  • For example:

    * Chapter 2
    :PROPERTIES:
    :EXPORT_FILE_NAME: chapter2
    :END:
    

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

5

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.

2

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" )

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.