Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

emacs

org-mode

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?

like image 761
troutwine Avatar asked Oct 14 '12 01:10

troutwine


2 Answers

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.
like image 191
N.N. Avatar answered Nov 04 '22 22:11

N.N.


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))
like image 38
Oleg Pavliv Avatar answered Nov 04 '22 22:11

Oleg Pavliv