Mkdocs-material: Disable toc

Created on 6 Oct 2017  Â·  13Comments  Â·  Source: squidfunk/mkdocs-material

Is there an option to disable Table of contents on all page?

Most helpful comment

Is there any way of embedding such code but only in certain .md files - not for every page?
many thanks

All 13 comments

@nodesocket did you find a solution to this?

Just remove toc from your mkdocs.yml under markdown_extensions.

There are currently no extensions listed in my mkdocs.yml file. It _appears_ toc is on by default, which contradicts this:

The following extensions are not enabled by default [...] toc
mkdocs-material/getting-started/#extensions

What am I missing?

Oh, that's right. I found this issue on the MkDocs tracker: https://github.com/mkdocs/mkdocs/issues/454. Also see the linked issue.

Currently MkDocs and Python Markdown provide no options to hide the toc, so it's always rendered. You can, however, use CSS to hide it quickly:

.md-sidebar--secondary {
  display: none;
}

Okay yeah, I had commented out the toc block from base.html – same result – but I think I like that better.

My underlying issue is that I'd like md-content__inner to expand to fill the right side of the page. This is because there are tables in the markdown that get cutoff. I set md-content--inner to overflow-x: scroll, which is better but not ideal.

Is there a reasonable means of getting the inner content to expand into the toc block space in the render? This is probably simple, but I haven't been able to figure it out. Thanks.

@connercowling

@media only screen and (min-width: 60em) {
  .md-content {
    margin-right: 0;
  }
}

@makshh works great. Much appreciated.

@max-ci @connerxyz @squidfunk Hi. I am new to this web designing stuff. Where do we have to add max-ci code (and /or squidfunk's code ?) so as to remove toc and use that space with our center content ? I tried adding in mkdocs.yml but got no success.

It's explained in the customization guide.

Is there any way of embedding such code but only in certain .md files - not for every page?
many thanks

Thanks for your nice comments on this topic. After I added the CSS I sometimes saw a flickering with the TOC disappearing after 200ms so I also added a constraint for only rendering heading #1 which is basically like saying don't render anything since the TOC starts at heading #2

markdown_extensions:
    - toc:
        toc_depth : "1-1"

Thanks for your nice comments on this topic. After I added the CSS I sometimes saw a flickering with the TOC disappearing after 200ms so I also added a constraint for only rendering heading #1 which is basically like saying don't render anything since the TOC starts at heading #2

markdown_extensions:
    - toc:
        toc_depth : "1-1"

Thank you, it works!

@connerxyz I have the same requirement with you, I need add the space for md-content__inner to hold the table. Where did you make the changes on md-content__inner, I add the below into the extra.css, but it doesn't work. And is there a way to make it take effect just on some pages.
@media only screen and (min-width: 60em) {
.md-content {
margin-right: 0;
}
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BamBalaam picture BamBalaam  Â·  4Comments

madrus picture madrus  Â·  3Comments

lupupitkanen picture lupupitkanen  Â·  4Comments

michael-nok picture michael-nok  Â·  3Comments

bborysenko picture bborysenko  Â·  4Comments