21

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'
bad_coder
  • 11,289
  • 20
  • 44
  • 72
funky-future
  • 3,716
  • 1
  • 30
  • 43
  • 1
    Same as http://stackoverflow.com/q/25243482/407651 – mzjn Mar 26 '16 at 18:57
  • Does this answer your question? [How can I link the generated index page in ReadTheDocs navigation bar?](https://stackoverflow.com/questions/40556423/how-can-i-link-the-generated-index-page-in-readthedocs-navigation-bar) – Paebbels Aug 09 '20 at 19:05
  • Can you please explain the equation: ``4 years, 2 months > 4 years, 9 months`` @Paebbles? – Akib Azmain Turja Jan 10 '21 at 11:59

2 Answers2

8

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:

Dirk Schiller
  • 491
  • 6
  • 18
2

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.

funky-future
  • 3,716
  • 1
  • 30
  • 43