I'd like to have a link to the automatically generated index in the sidebar when using sphinx-rtd-theme
. I've tried adding it to the toctree:
.. toctree::
first
second
Index <:ref:`genindex`>
but this resulted in
WARNING: toctree contains reference to nonexisting document u':ref:`geinindex`'
from Sphinx and no other effect.
I think I could simply hardcode the index in the theme layout.html
file, but perhaps there is some better way, not involving modifying the standard theme?
TIA for any hints!
See the Sphinx HTML sidebars documentation for more information. By default, this theme comes with these three theme-specific sidebar elements enabled on all pages: sidebar-logo.html: Displays the logo and site title. search-field.html: A bootstrap-based search bar (from the PyData Sphinx Theme)
Open this file in your web browser to see your docs. Your Sphinx project is built. Edit your files and rebuild until you like what you see, then commit your changes and push to your public repository. Once you have Sphinx documentation in a public repository, you can start using Read the Docs by importing your docs.
You can use Markdown using MyST and reStructuredText in the same Sphinx project. We support this natively on Read the Docs, and you can do it locally: You can now continue writing your docs in .md files and it will work with Sphinx.
This blog postprovides some info about the design, but in short, the theme aims to solve the limitations of Sphinx’s default navigation setup, where only a small portion of your docs were accessible in the sidebar. Our theme is also meant to work well on mobile and tablet devices. Contributing to the theme¶
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:
_templates
folder under your sphinx docs folder.conf.py
, e.g. templates_path = ['_templates']
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 %}
How about:
.. toctree::
first
second
* :ref:`genindex`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With