You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Org模式导出HTML时自定义‘Table of Contents’目录标题?

Customizing the Org Mode HTML Export TOC Title

Absolutely! You don’t need post-export JavaScript workarounds—Org mode has built-in tools to set a custom TOC title directly during export. Here are the two most practical methods:

1. Per-file or Global Variable Setup

The org-html-toc-title variable controls the text of the TOC’s H2 heading. You can set it either for a single document or across all your exports.

For a single Org file

Add this line at the top of your document (within the initial settings block) to override the title just for that file:

#+BIND: org-html-toc-title "目录"  ;; Replace with your desired title text

Just make sure you have TOC enabled in your #+OPTIONS (e.g., #+OPTIONS: toc:t to display the table of contents).

For all exports globally

Add this to your Emacs configuration file (like init.el or .emacs) to set a default custom title for every Org-to-HTML export:

(setq org-html-toc-title "目录")  ;; Use your preferred language's title here

2. Custom HTML Template (for advanced control)

If you want more control over the TOC’s HTML structure along with the title, create a custom HTML template:

  1. Create a template file (e.g., my-org-template.html) and modify the TOC section to use your custom title:
<div id="table-of-contents">
  <h2>Your Custom TOC Title</h2>
  <div id="text-table-of-contents">
    %TOC%
  </div>
</div>
  1. Reference this template in your Org file:
#+HTML_TEMPLATE: /path/to/my-org-template.html

This method is ideal if you want to tweak styling or structure beyond just the title text.

Both approaches will generate the TOC with your desired title right on export—no post-processing required.

内容的提问来源于stack exchange,提问作者Giovanni Gigante

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 08:32:33