Hide Search Bar #6572
-
Hi, I've enabled the search feature but would like to hide it on certain pages. Is this currently possible, and if so, how? I tried this at the top of my markdown page, but it doesn't seem to work: ---
hide:
- navigation
- toc
- search
---
# Example
... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
This functionality is not implemented in the theme, as straightforwardly as hiding navigation or the toc. To hide the search input with CSS you can use this: .md-search {
display: none;
} Instead of Another approach would be to mimic the way mkdocs-material/src/templates/base.html Lines 297 to 314 in 246266f You can override the IMO the CSS approach is better than overriding the templates. Also keep in mind, that this will still put the code in the HTML and it can be detected by web scrapers etc. it's only a visual change for the rendered website. |
Beta Was this translation helpful? Give feedback.
This functionality is not implemented in the theme, as straightforwardly as hiding navigation or the toc.
However, you can add your own CSS to hide the elements: https://squidfunk.github.io/mkdocs-material/customization/#additional-css
But instead of adding the
extra.css
file to themkdocs.yml
file you can add a<link rel="stylesheet" href="/stylesheets/extra.css">
tag to your Markdown page. When setting thehref
please mind the absolute path with/
at the beginning or/repository-name/
for GitHub pages.To hide the search input with CSS you can use this:
Instead of
display: none;
,visibility: hidden;
can also be used, with a different behaviour.Another a…