How do I add the "previous chapter" and "next chapter" links in the documentation generated by Sphinx?
When I look at the documentation, most of the pages have the previous chapter and next chapter link / button at the bottom, like virtualenv , I can't figure out how to do this for my project documentation using the Sphinx tool . Can anyone tell me how this works or point me to a useful resource (although I've searched many times already)?
source to share
The sphinx-doc.org documentation on templates mentions variables next
and prev
:
The next document is for navigation. This variable is either false or has two attributes link and title. The header contains HTML markup. For example, to create a link to the following page, you can use this piece of code:
{% if next %}
<a href="{{ next.link|e }}">{{ next.title }}</a>
{% endif %}
See more: http://sphinx-doc.org/templating.html#next
You can use them anywhere in your Sphinx template and style with CSS accordingly.
A complete example could be:
<ul class="footer_nav">
{%- if prev %}
<li class="prev">
Previous topic: <a href="{{ prev.link|e }}">{{ prev.title }}</a>
</li>
{%- endif %}
{%- if next %}
<li class="next">
Next topic: <a href="{{ next.link|e }}">{{ next.title }}</a>
</li>
{%- endif %}
</ul>
source to share