I noticed this strange behaviour when all the headlines are in the same level, say level 2, when the org file get exported to markdown, all the levels are bump to level 1.

Below is an example I run with Emacs -Q.

enter image description here

Is there a way to make org-mode respects the headline levels in exporting to markdown? in this example, they shuold be level 2 headlines, starts with two ##.

1 Answer 1


Try this:

#+BIND: org-md-toplevel-hlevel 2

** Heading

** Another

You will need to enable #+BIND keywords beforehand by customizing org-export-allow-bind-keywords to t.

EDIT: the #+BIND: method allows you to set the variable for the file so that it applies during export only. But a local file variable setting would probably work just as well in this case. Add

# -*- org-md-toplevel-hlevel: 2 -*-

at the very top of the file, or

* COMMENT Local variables
# Local Variables:
# org-md-toplevel-hlevel: 2
# End:

at the very bottom of the file (and always make sure that it stays there even if you add more stuff to the file).

The reason I used #+BIND: originally is that this variable is only useful when you are exporting: when you want to set a variable only during export, #+BIND: is indispensable. In this case however it does not really matter: setting the variable when the file is opened (as is the case with local file variables), rather than when it is exported, will not affect anything: the variable will be set but it will just sit there quietly not bothering anyone; it will only spring into action when/if you export the file.

  • great! this is exactly what I need. thank you very much! Commented Mar 30, 2023 at 8:58
  • is there another way to set org-md-toplevel-hlevel for the current file without using #+BIND? Commented Dec 16, 2023 at 13:57
  • 1
    Edited the question to add that info, Search for questions tagged [file-local-variables] as well, although the manual (linked in the EDIT above) is the ultimate authority.
    – NickD
    Commented Dec 16, 2023 at 15:46

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.