Chinaxing
Chinaxing

Reputation: 8874

How can I use org-mode to export html with TOC (table-of-content) when body-only is t?

I use org-mode to export the content of a blog, then use jekyll to produce the result blog page.

I found that when I set the body-only to true, the org-project export does not contain the TOC(table of content) of the org file.

How can I config to let emacs produce the TOC?

Here is my .emacs configuration:

;; org-mode project define                                                                                                            
(setq org-publish-project-alist
      '(
        ("org-blog-content"
         ;; Path to your org files.                                                                                                   
         :base-directory "~/ChinaXing.org/org/"
         :base-extension "org"

         ;; Path to your jekyll project.                                                                                              
         :publishing-directory "~/ChinaXing.org/jekyll/"
         :recursive t
         :publishing-function org-publish-org-to-html
         :headline-levels 4
         :html-extension "html"
         :table-of-contents t
         :body-only t ;; Only export section between <body></body>                                                                    
         )

        ("org-blog-static"
         :base-directory "~/ChinaXing.org/org/"
         :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|php"
         :publishing-directory "~/ChinaXing.org/jekyll/"
         :recursive t
         :publishing-function org-publish-attachment)
        ("blog" :components ("org-blog-content" "org-blog-static"))
        ))

Upvotes: 2

Views: 3237

Answers (1)

Thomas
Thomas

Reputation: 17422

According to this post to the org-mode email list, the...

[...] HTML exporter will refuse to include a TOC if body-only is t; the atom exporter and a "send HTML messages with Wanderlust" hack relied on that behaviour, which is why this was not changed in the official Org repository.

One solution is to patch the source code of org-mode, as is done here:

http://thread.gmane.org/gmane.emacs.orgmode/24227

Ian Barton apparently have implemented an alternative way to generate the TOC dynamically using jQuery. You may consider replying to this thread post if you are interested in details about that solution.

Upvotes: 1

Related Questions