Search code examples
python-sphinxrestructuredtext

Remove previous and next topic from html, sphinx


I would like to remove the Next topic and Previous topic from my html pages.

I have tried setting prev_next_buttons_location to False in html_theme_options of conf.py but I got a WARNING telling me that this option is not available for my current theme (which is nature).

Another way to remove them would be to not declare the other rst sources from the index's table of contents (my first version of the document was with only index.rst and I did not have the Next and Previous buttons): I tried with the flag :hidden: of .. toctree:: but I still have them. Removing .. toctree:: is not a solution because I have WARNINGS for each files that are not declared.

Should I change my theme to another that supports prev_next_buttons_location? (I really do not want to change my theme)

Is there a way to remove the buttons from my generated pages?


Solution

  • Another way to express the problem is: how to not include some files into the toctree ?

    First I tried to add the files in exclude_patterns but then they were not generated to html. I went back to the doc and read this

    Use exclude_patterns to explicitly exclude documents or directories from building completely. Use the “orphan” metadata to let a document be built, but notify Sphinx that it is not reachable via a toctree.

    Then I followed the link about "orphan" metadata: https://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html#metadata

    And this is the solution: just add :orphan: in the beginning of the file. As written in the doc:

    If set, warnings about this file not being included in any toctree will be suppressed.

    So, this solved the problem.