Sphinx - 如何维护页面之间的侧边栏内容?

问题描述

我有这个源目录结构:

.
├── conf.py
├── devel
│   └── python
│       ├── Controles de flujo,condicionales y bucles.md
│       ├── Encapsulamiento.md
|       ├── (...)
├── index.rst
├── _static
├── _templates
└── webdevel

这是我的index.rst

¡Bienvenidos a Echemos un bitstazo!
======================================================

Este es mi espacio de documentación personal dónde almaceno todo tipo de conocimientos relacionados con la administración de sistemas y redes informáticas; desarrollo y otros temas varios de IT.

.. toctree::
   :maxdepth: 1 
   :caption: Administración de sistemas

   devel/python/python

Índice y tablas
==================

* :ref:`genindex`
* :ref:`search`

这是我的python.rst

Python
======================================================

.. toctree::
   :maxdepth: 1
   :caption: Contenido:
   :glob:

   *

我的conf.py

project = 'Echemos un bitstazo ~ Wiki'
copyright = '2021,Álvaro Castillo'
author = 'Álvaro Castillo'
extensions = [ 'myst_parser'
]
templates_path = ['_templates']
language = 'es'
exclude_patterns = []
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']

执行sphinx-build -b html source build后,我得到了index.html、python.html...等

我有这个索引菜单

Index menu

我有这个 Python 菜单

enter image description here

但是,当我访问另一个像 Encapsulamiento 这样的页面时,菜单会发生变化。

enter image description here

如何修复这个显示所有帖子的幻灯片菜单栏,就像在 python.html 中一样?

解决方法

Encapsulamiento 添加到 toctree 中的 index.rst

.. toctree::
    :maxdepth: 2
    :caption: Administración de sistemas

    devel/python/python
    path/to/encapsulamiento

同时将 maxdepth 更改为 2