2

I have the following in org-mode:

#+TITLE: My title                                                                                                                                      
#+SUBTITLE: My subtitle

Both show up just fine when exporting to HTML but are nowhere to be seen when exporting to Markdown. Why is that and how to fix it?

PS: I'm using Emacs version 27.1.

2
  • Yes - ox-html preserves these as metadata using the function org-html--build-meta-info; ox-md does nothing similar. I don't know much about Markdown, but you might send a bug report with M-x org-submit-bug-report and see what the maintainers have to say about it.
    – NickD
    Commented Feb 17, 2023 at 16:46
  • stackoverflow.com/questions/17097894/… seems to indicate that there is no title markup in Markdown :-) Of course, you can find another dialect (or invent your own - everybody seems to have done it...) - but there might not be an official way to specify a title. Let me repeat however: I don't know very much about Markdown.
    – NickD
    Commented Feb 17, 2023 at 21:27

1 Answer 1

1

Using the info provided by NickD, and inspecting org-html--build-meta-info it becomes quite straightforward to include 'some kind of title' in the md export.

You could advise org-md-template as follows to export the title:

(defun org-md-export-title-advice (orig-fun &rest args)
  (let* ((res (apply orig-fun args))
         (title (org-element-interpret-data (plist-get (nth 1 args) :title))))
    (concat "# " title "\n"
            res)))

(advice-add 'org-md-template :around #'org-md-export-title-advice)

Of course, here I am simply formatting the title as a level-1 heading. However, you could use any of the tricks from that link in NickD's comment (e.g. this answer) to modify the formatting (just change the args in the concat form).

Alternatively, you could also just redefine the org-md-template function directly.

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.