Sphinx toctree in sidebar ONLY
Asked Answered
K

1

7

I'm new to Sphinx and have been searching for a solution to this question for a while.

My Index Page is made from index.rst which contains a toctree. The page displays the TOC in the body as well as the sidebar. I'd like to show the TOC on the sidebar ONLY, with space to enter some text in each page body instead. In particular, the main "Welcome to My Place", currently the index.html and index.rst should be just a paragraph of blurb instead of the TOC.

I have tried this:

Welcome to My Place
==================

.. toctree::
   :hidden:
   :maxdepth: 2
   :caption: Contents:

But that removes the TOC from the page AND the sidebar. How can I get that to work?

EDIT: here's how it appears, I'd like the TOC to ONLY appear in the sidebar. Screen shot

Kelcie answered 24/1, 2019 at 14:29 Comment(4)
Sphinx 2.2.11-id64-release (95ae9a6) sphinx-build 1.8.3 No custom themes, so I'm assuming it's sphinxdocKelcie
The default theme is alabaster. See sphinx-doc.org/en/master/usage/theming.html#builtin-themesLaborious
Yes, it is alabaster that I'm using.Kelcie
I cannot reproduce the problem using Alabaster.Laborious
J
7

You can do this by including a separate file for the toctree and point the variable master_doc in conf.py to this file.


conf.py

# ...
master_doc = "contents"
# ...rest of the document

contents.rst

.. toctree::

   example

index.rst

# Landing Page
 Welcome!
Jehiah answered 21/5, 2021 at 7:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.