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

如何移除Sphinx索引页面底部重复的toc?

解决Sphinx文档重复TOC问题

你遇到的重复TOC问题,根源在于代码里同时做了两件事:

  • 用.. include:: readme.rst将readme内容直接嵌入首页
  • 在Introduction的toctree中添加了readme条目

这导致readme相关内容被渲染了两次,进而出现重复的TOC。可以通过以下两种方式解决:

方案一:保留toctree的readme入口,移除直接嵌入的语句

修改后的index.rst代码如下:

Welcome to the documentation!
=============================

.. _INTRODUCTION::
.. toctree::
   :maxdepth: 1
   :caption: Introduction

   readme

.. toctree::
   :maxdepth: 1
   :caption: Contents:

   gazetimation


Indices and tables
==================

* :ref:`genindex`

方案二:保留首页嵌入readme内容,移除toctree中的readme条目

修改后的index.rst代码如下:

Welcome to the documentation!
=============================

.. include:: readme.rst

.. _INTRODUCTION::
.. toctree::
   :maxdepth: 1
   :caption: Introduction

.. toctree::
   :maxdepth: 1
   :caption: Contents:

   gazetimation


Indices and tables
==================

* :ref:`genindex`

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.21 01:48:38