troutwine
troutwine

Reputation: 3821

How to disable automatic title inclusion in org-mode HTML export?

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?

Upvotes: 9

Views: 3402

Answers (2)

N.N.
N.N.

Reputation: 8502

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.

Upvotes: 8

Oleg Pavliv
Oleg Pavliv

Reputation: 21162

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

Upvotes: 5

Related Questions