How to add Sphinx-generated index to the sidebar when using Read the Docs theme?
How about:
.. toctree::
first
second
* :ref:`genindex`
It's easy if you understand how Sphinx and Jinja work. Unfortunately the Sphinx docs on templating don't give you enough info if you don't. In short, you'll have to override the template:
- Make sure you have a
_templates
folder under your sphinx docs folder. - Make sure it is listed in your
conf.py
, e.g.templates_path = ['_templates']
- Create a file inside the folder called
layout.html
. Put this snippet inside and save. The exclamation point/mark forces jinja to use the parent template. Don't forget it, or you'll get a recursion error. You only need to override the
menu
block.{% extends "!layout.html" %} {% block menu %} {{ super() }} <a href="genindex.html">Index</a> {% endblock %}
@Gringo's code got me close. Here is how to match the formatting. @brad also has this in the comments but hard to read wo line spacing. Note, read @Gringo's instructions on where to put this code.
{% extends "!layout.html" %}
{% block menu %}
{{ super() }}
<p class="caption">
<span class="caption-text">Indices</span>
</p>
<ul>
<li class="toctree-l1"><a href= "{{pathto('genindex.html', 1)}}">Everything</a></li>
<li class="toctree-l1"><a href= "{{pathto('py-modindex.html', 1)}}">Module Index</a></li>
</ul>
{% endblock %}