9

I have an org-mode project with many small org files that I'd like to export to HTML. I have not set #+TITLE in many files as they do not have proper titles. I find on export that the partial first sentence is exported as the document's title.

For instance, an org document like so:

This is a short file.

Mary had a little lamb, etc.

Will be exported to have the following HTML:

*snip*
<div id="content">
<h1 class="title">This is a short file.</h1>


<p>Mary had a little lamb, etc.</p>
*snip*

I would prefer to see both sentences in the above file be marked as paragraphs. How can I disable the automatic divination of titles?

2 Answers 2

8

To avoid the first line becoming the title you can set an empty title:

#+Title:

This is a short file.

Mary had a little lamb, etc.
1
  • 1
    This also disables the <title>
    – Alex
    Apr 28, 2016 at 19:44
5

If you take a look on the code of org-export-region-as-html you will see the following fragment

(title (or (and subtree-p (org-export-get-title-from-subtree))
           (plist-get opt-plist :title)
           (and (not
                 (plist-get opt-plist :skip-before-1st-heading))
                (org-export-grab-title-from-buffer))
           (and buffer-file-name
                (file-name-sans-extension
                 (file-name-nondirectory buffer-file-name)))
           "UNTITLED"))

A function org-export-grab-title-from-buffer is called if no title is defined. You can disable this function by advising it

(defadvice org-export-grab-title-from-buffer (around org-export-grab-title-from-buffer-disable activate))
4
  • Could you link to documentation describing this facility? How did you know of this?
    – troutwine
    Oct 14, 2012 at 7:34
  • 1
    @troutwine I think he just read the source.. actually defadvice is not a setting provided by Org, its rathar created by the user with lisp magic.
    – kindahero
    Oct 14, 2012 at 9:52
  • 2
    You may tell org mode that there is no title then it will not have a title. You don't need to hack on it.
    – grettke
    Apr 3, 2015 at 0:12
  • This answer is no longer applicable: the function org-export-grab-title-from-buffer does not exist as of 2014-05-22, so any modern version of org (9.x.x) does not have it.
    – NickD
    Jun 12, 2018 at 17:48

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.