0

Lets say I have two .rst files, a welcome page (the index) and an API page. I would like them both to have identical toctrees, so it is easy to navigate from the one page to the other.

index.rst:

Welcome!
========

Welcome to these awesome docs!

api.rst:

API
===

Here is some API stuff...

I tried adding a toctree to index.rst, something like this:

.. toctree::
   :hidden:

   index
   api

However then my toctree gets nested:

enter image description here

I do not only want to add

.. toctree::
   :hidden:

   api

to index.rst and

.. toctree::
   :hidden:

   index

to api.rst, since that means that the sidebar is different between pages.

How do I add a global index to my project? One that is the same no matter which page I am on?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Maarten-vd-Sande
  • 3,413
  • 10
  • 27
  • 1
    Remove `index` from the `toctree` as it is self referential and causing the nesting. Does that achieve what you desire? – Steve Piercy Mar 09 '20 at 20:43
  • No, I guess I wasn't really clear. But I would like each page (index and api) to have the same sidebar. So somehow it needs to self-refer. If I remove index from the toctree it "works", however welcome isn't in the toctree anymore. – Maarten-vd-Sande Mar 09 '20 at 21:01
  • @StevePiercy I edited my post to make it (hopefully) more clear in what I want. – Maarten-vd-Sande Mar 10 '20 at 08:14
  • I am still not clear what you want to achieve. The left-hand navigation is always relative to the currently viewed document, which is by design of `toctree`. If you want the navigation to remain the same, then it must be a single page. Alternatively you could edit the Jinja2 templates with static global navigation. – Steve Piercy Mar 10 '20 at 08:29
  • @StevePiercy, I was hoping something "out-of-the-box" exists for this. I don't like it when it's one big page. Seems like I will have to fiddle witht he Jinja2 templates :(. Thanks for your help – Maarten-vd-Sande Mar 10 '20 at 09:06

0 Answers0