Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sub navigation broken if page doesn't start with title #770

Closed
marcelstoer opened this issue Dec 7, 2015 · 4 comments
Closed

Sub navigation broken if page doesn't start with title #770

marcelstoer opened this issue Dec 7, 2015 · 4 comments
Labels
Needs design decision Theme-mkdocs Issues specifically involving the mkdocs theme.
Milestone

Comments

@marcelstoer
Copy link

marcelstoer commented Dec 7, 2015

In order to avoid duplicate links in the (side) navigation it was suggested to remove the title of the page i.e. remove the header 1 or replace it with <h1> (#308 (comment)).

However, if you do this and omit the title MkDocs fails at rendering the (side) navigation correctly as it includes more than just header 1 & 2. If you start playing around with lower rank headers the behavior becomes totally incomprehensible.

mkdocs-side-navigation-error

In order to avoid any such confusion and undefined(?) behavior it might make sense to introduce a new configuration parameter that defines which max header level should be included in the navigation. That was what I initially thought was going on when I posted to your group https://groups.google.com/d/msg/mkdocs/JRufth2iBaE/L_W0ZsWlDAAJ.

marcelstoer added a commit to nodemcu/nodemcu-firmware that referenced this issue Jan 31, 2016
Had to slightly tweak the Markdown headers due to
mkdocs/mkdocs#770 :(.

Fixes #990.
ABonner pushed a commit to ABonner/nodemcu-firmware that referenced this issue Feb 11, 2016
Had to slightly tweak the Markdown headers due to
mkdocs/mkdocs#770 :(.

Fixes nodemcu#990.
@d0ugal
Copy link
Member

d0ugal commented Feb 24, 2016

The reason this happens is to do with how python-markdown creates the TOC tree which we then use. We include the top two levels in the table of contents, not h1 and h2.

So, this is really happening by design and as I would expect. It is confusing however, I think we should at some point consider a way of allowing users to customise this behaviour.

@marcelstoer
Copy link
Author

I've just gone through #316 again and I agree that mkdocs.yml > md title > filename title would be a good strategy to find the TOC label (i.e. navigation item label).

Yet, I see perfectly valid use cases for TOC label != page titel. In such cases the page title shouldn't be part of the TOC. That's why I'd like to keep this open.

we should at some point consider a way of allowing users to customise this behaviour

What would help in those cases if you could define that markdown header N to header M should be part of the TOC (e.g. 2-3 but not 1 because that's the page title).

OR am I just missing something? How would you suggest we organize this http://nodemcu.readthedocs.org/en/dev/en/modules/hx711/? The firmware has dozens of modules and each should be listed in the TOC with its "shortname" while module page's title should/can be different.

@d0ugal
Copy link
Member

d0ugal commented Feb 25, 2016

You could just hide the first item in the table of contents with a tiny CSS addition. This would maintain the header tree for MkDocs to use and never show the first H1.

If you ever wanted to show an H1 in the table of contents it would be an issue tho'

See: #318 (comment)

@memeplex
Copy link
Contributor

memeplex commented Aug 4, 2016

The css/js hack would be a real solution if the toc template always generated all header levels with an appropriately nested structure, letting the user manipulate it client-side. But in practice themes are opinionated (for good) regarding the way they render the toc, thus selectively hiding some level just leaves you with the wrong structure (for example, a one level hierarchy for a theme expecting two levels).

@waylan waylan added the Theme-general Issues involving the theme related code within MkDocs label Nov 1, 2017
@waylan waylan added this to the Post 1.0 milestone Feb 6, 2018
@waylan waylan added Theme-mkdocs Issues specifically involving the mkdocs theme. and removed Theme-general Issues involving the theme related code within MkDocs labels Aug 22, 2018
@waylan waylan modified the milestones: Post 1.0, 1.1 Aug 23, 2018
@waylan waylan closed this as completed in 37e645d Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs design decision Theme-mkdocs Issues specifically involving the mkdocs theme.
Projects
None yet
Development

No branches or pull requests

4 participants