The ReadTheDocs and default theme should display the same headings in the side bar
Hi here,
thank you for mkdocs!
I noticed this inconsistency between the two themes shipped by default (more details below). I know the ReadTheDocs theme is third-party, but I would argue that only switching the theme should not force you to change any of the markdown files.
The problem is that the RTD theme always ignores the top-level heading, be it # or ## or more. It then only takes the next inner level subheadings, but only the ones in the first section. So it forces you to always define the page title as the highest heading, which is annoying because in both themes the page title is already displayed as part of navigation elements and is therefore redundant (as long as there are more than one page of documentation). So for example, if you have this markdown:
Title: Page title
# First section
## subsection 1
## subsection 2
# Second section
## subsection 3
## subsection 4you get the following sidebar:
Page title
- subsection 1
- subsection 2Whereas with the mkdocs theme, you get, as wanted:
- First section
- subsection 1
- subsection 2
- Second section
- subsection 3
- subsection 4This has been somewhat under discussion here:
Additionally, the TOC data does not include any indication of the h-level of each item. It only knows the hierarchy of the items in relation to eachother, not that the top level actually comes from an
h2(for example). Therefore, there would be no way to have the theme only conditionally ignore the top level if it was from anh1, but not ignore it if it was from anh2.Of course, a theme could have a config option which would enable/disable including the top level. However, the
readthedocstheme is a clone of the Sphinx theme of the same name and the upstream theme doesn't have such a feature so we will not be adding that feature either. However, it could certainly be added to a third-party theme. I believe there are even a few forks out there of thereadthedocstheme. Perhaps one of them has implemented the feature or would be wiling to.
Originally posted by @waylan in #2215
However given that this creates an unexpected difference in the outputs from both themes, I think this might deserve a fix, or a user configuration option.
Source: mkdocs/mkdocs