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

Disable toc #478

Closed
nodesocket opened this issue Oct 6, 2017 · 15 comments
Closed

Disable toc #478

nodesocket opened this issue Oct 6, 2017 · 15 comments

Comments

@nodesocket
Copy link

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

@connerxyz
Copy link

@nodesocket did you find a solution to this?

@squidfunk
Copy link
Owner

Just remove toc from your mkdocs.yml under markdown_extensions.

@connerxyz
Copy link

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?

@squidfunk
Copy link
Owner

squidfunk commented Oct 13, 2017

Oh, that's right. I found this issue on the MkDocs tracker: mkdocs/mkdocs#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;
}

@connerxyz
Copy link

connerxyz commented Oct 13, 2017

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.

@max-ci
Copy link

max-ci commented Oct 13, 2017

@connercowling

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

@connerxyz
Copy link

@makshh works great. Much appreciated.

@root-ansh
Copy link

root-ansh commented Sep 15, 2019

@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.

@squidfunk
Copy link
Owner

squidfunk commented Sep 15, 2019

It's explained in the customization guide.

@nigelwelham
Copy link

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

@clouddistortion
Copy link

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"

@slavianap
Copy link

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!

@hpcaicom
Copy link

hpcaicom commented Jul 5, 2020

@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;
}
}

@qmel
Copy link

qmel commented Feb 8, 2023

for me

...
# to exclude any headers from table of content and search
'toc' : {
    'baselevel' : 2,
    'toc_depth' : 1
}
...

and

...
'toc' : {
    'toc_depth' : 0
}
...

worked well in 1.4.2 version

@jhshi31
Copy link

jhshi31 commented Apr 19, 2024

I think I found a solution. You can manually put this code block in your .md files to prevent the toc from appearing.

---
hide:
  - navigation
  - toc
---

https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation/#hiding-the-sidebars

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests