Skip to content

restrict header levels in TOC #256

Closed

Description

@xin-jin

I only need headers of levels 1 or 2 to be shown in TOC (as TOC would be too long if I have many subsections), but it seems that by default levels 1-4 would all show up. Is there an option to remove headers with levels >2 from TOC? Thanks.

EDIT: moreover, if I use the theme "readthedocs", all headers seems to be "of the same level" in the TOC.

Activity

  1. lovelydinosaur commented on Dec 8, 2014

    @lovelydinosaur
    Collaborator

    No there's not currently any option to allow that.
    For now you'd need to use a custom theme if the existing ones don't meet your needs.

  2. ePirat commented on Jan 4, 2015

    @ePirat

    Why was this closed? I think this is a very important thing, specially for large docs, I do not want all h3 and h4's to be listed in the TOC (using RTD theme, where this has really a annoying impact, since it makes the sidebar super long)

  3. tverbeke commented on Dec 18, 2016

    @tverbeke

    @tomchristie The issue is still present in version 0.16.0 - I agree with @ePirat that it may be better to reopen for the same reasons.

  4. waylan commented on Dec 18, 2016

    @waylan
    Contributor

    I can't read @tomchristie's mind, but I know I'm not interested in developing a complex theme with many config settings that meets every conceivable need. Users can create their own custom themes (there is already a few third party themes which address some of these needs), and/or override bits and pieces of the existing themes to create whatever custom functionality they want/need. There is not any additional action we need to take to make that possible for users so there is no need to leave this issue open.

  5. tverbeke commented on Dec 18, 2016

    @tverbeke

    IMHO toc depth is not really 'every conceivable need' at least for a documentation system, but I can understand opinions diverge. On the other hand, the fact that in the 'readthedocs' theme all headers seem to be 'of the same level' in the TOC (as reported by the OP) is not a feature request, rather a bug.

  6. waylan commented on Dec 18, 2016

    @waylan
    Contributor

    The issues with the readthedocs theme are covered by #588. You should follow up there if the specific issue you are having is not already mentioned.

  7. lovelydinosaur commented on Dec 19, 2016

    @lovelydinosaur
    Collaborator

    I'm not really spending time on MkDocs lately myself, so <shrug>.
    I assume this only applies to the RTD theme right? The mkdocs theme only displays 2 levels.

  8. funkyfuture commented on May 4, 2017

    @funkyfuture
    Contributor

    am i wrong or could this rather simply be solved by restricting the items by their depth when the context is populated? rather than tinkering on the template level.

  9. waylan commented on May 4, 2017

    @waylan
    Contributor

    @funkyfuture the TOC is obtained from the TOC extension to the Markdown parser. Therefore, the entire TOC is already created before MkDocs ever sees it. Whether it is then restricted when the context is created or in the template is simply an implementation detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions