funky-future
funky-future

Reputation: 3958

How can i include the `genindex` in a Sphinx TOC?

Sphinx generates an index named genindex when building a documentation and therefore forbids to use that name for a document. Now, how would I include a link to that index in a table of contents?

I've tried this:

.. toctree::
   :maxdepth: 2

   genindex
   api


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

* :ref:`genindex`

While the last line does create a link to that index in the document, the build doesn't know the reference when creating the TOC:

WARNING: toctree contains reference to nonexisting document 'genindex'

Upvotes: 22

Views: 9499

Answers (2)

funky-future
funky-future

Reputation: 3958

Good news, everyone! A patch has been merged and was released with Sphinx 5.2.0. Now genindex, modindex and search can be included as TOC items without further ado.

Upvotes: 3

Dirk Schiller
Dirk Schiller

Reputation: 534

Create a File genindex.rst with the following Content:

Index
=====

In your index.rst add:

.. toctree::
   :hidden:

   genindex

If you you also want to have the Link and Text "Index" on the Site and not only in the left Navigation then remove :hidden:

Upvotes: 9

Related Questions