2020-07-17 14:08:27 +03:00
|
|
|
|
---
|
|
|
|
|
template: overrides/main.html
|
|
|
|
|
---
|
|
|
|
|
|
2020-07-20 16:18:09 +03:00
|
|
|
|
# Setting up navigation
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
|
|
|
|
A clear and concise navigation structure is an important aspect of good project
|
2020-11-15 17:34:44 +03:00
|
|
|
|
documentation. Material for MkDocs provides a multitude of options to configure
|
|
|
|
|
the behavior of navigational elements, including [tabs][1] and [sections][2],
|
|
|
|
|
and its flag-ship feature: [instant loading][3].
|
2020-11-01 17:43:26 +03:00
|
|
|
|
|
|
|
|
|
[1]: #navigation-tabs
|
|
|
|
|
[2]: #navigation-sections
|
|
|
|
|
[3]: #instant-loading
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
|
|
|
|
|
### Instant loading
|
|
|
|
|
|
2020-11-01 17:43:26 +03:00
|
|
|
|
[:octicons-file-code-24: Source][4] ·
|
2020-09-27 20:21:16 +03:00
|
|
|
|
:octicons-unlock-24: Feature flag
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
2020-11-01 17:43:26 +03:00
|
|
|
|
When _instant loading_ is enabled, clicks on all internal links will be
|
2021-01-31 21:23:28 +03:00
|
|
|
|
intercepted and dispatched via [XHR][5] without fully reloading the page. Add
|
|
|
|
|
the following lines to `mkdocs.yml`:
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
features:
|
2020-09-27 11:13:41 +03:00
|
|
|
|
- navigation.instant
|
2020-07-17 14:08:27 +03:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The resulting page is parsed and injected and all event handlers and components
|
2020-07-26 15:46:09 +03:00
|
|
|
|
are rebound automatically. This means that __Material for MkDocs behaves like a
|
2020-07-17 14:08:27 +03:00
|
|
|
|
Single Page Application__, which is especially useful for large documentation
|
2020-07-26 15:46:09 +03:00
|
|
|
|
sites that come with a massive search index, as the search index will now
|
|
|
|
|
remain intact in-between document switches.
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
2020-11-01 17:43:26 +03:00
|
|
|
|
_Material for MkDocs is the only MkDocs theme offering this feature._
|
2020-08-11 20:14:42 +03:00
|
|
|
|
|
2020-11-01 17:43:26 +03:00
|
|
|
|
[4]: https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/instant/index.ts
|
|
|
|
|
[5]: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest
|
2020-08-11 20:14:42 +03:00
|
|
|
|
|
2021-02-26 20:56:25 +03:00
|
|
|
|
### Anchor tracking
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[:octicons-file-code-24: Source][6] ·
|
2021-02-26 20:56:25 +03:00
|
|
|
|
:octicons-unlock-24: Feature flag ·
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[:octicons-heart-fill-24:{ .mdx-heart } Insiders only][6]{ .mdx-insiders }
|
2021-02-26 20:56:25 +03:00
|
|
|
|
|
|
|
|
|
When _anchor tracking_ is enabled, the URL in the address bar is automatically
|
|
|
|
|
updated with the active anchor as highlighted in the table of contents. Add the
|
|
|
|
|
following lines to `mkdocs.yml`:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
features:
|
|
|
|
|
- navigation.tracking
|
|
|
|
|
```
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[6]: ../insiders/index.md
|
|
|
|
|
|
2020-07-20 20:28:13 +03:00
|
|
|
|
### Navigation tabs
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[:octicons-file-code-24: Source][7] · :octicons-unlock-24: Feature flag
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
2020-11-01 17:43:26 +03:00
|
|
|
|
When _tabs_ are enabled, top-level sections are rendered in a menu layer below
|
2021-01-31 21:23:28 +03:00
|
|
|
|
the header for viewports above `1220px`, but remain as-is on mobile.[^1] Add
|
|
|
|
|
the following lines to `mkdocs.yml`:
|
2020-12-22 13:19:20 +03:00
|
|
|
|
|
|
|
|
|
[^1]:
|
|
|
|
|
Prior to version 6.2, navigation tabs had a slightly different behavior.
|
|
|
|
|
All top-level pages (i.e. all top-level entries that directly refer to an
|
|
|
|
|
`*.md` file) defined inside the `nav` entry of `mkdocs.yml` were grouped
|
|
|
|
|
under the first tab which received the title of the first page. This made
|
|
|
|
|
it impossible to include a top-level page (or external link) as a tab item,
|
|
|
|
|
as was reported in #1884 and #2072. From version 6.2 on, navigation tabs
|
|
|
|
|
include all top-level pages and sections.
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
features:
|
2020-09-27 11:13:41 +03:00
|
|
|
|
- navigation.tabs
|
2020-07-17 14:08:27 +03:00
|
|
|
|
```
|
|
|
|
|
|
2020-11-07 20:01:46 +03:00
|
|
|
|
=== "With tabs"
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[![With tabs][8]][8]
|
2020-11-07 20:01:46 +03:00
|
|
|
|
|
|
|
|
|
=== "Without tabs"
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[![Without tabs][9]][9]
|
2020-11-07 20:01:46 +03:00
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[7]: https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/tabs.html
|
|
|
|
|
[8]: ../assets/screenshots/navigation-tabs.png
|
|
|
|
|
[9]: ../assets/screenshots/navigation.png
|
2020-11-01 17:43:26 +03:00
|
|
|
|
|
2020-12-13 18:41:18 +03:00
|
|
|
|
#### Sticky navigation tabs
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[:octicons-file-code-24: Source][10] ·
|
2020-12-13 18:41:18 +03:00
|
|
|
|
:octicons-unlock-24: Feature flag ·
|
2021-09-23 10:23:42 +03:00
|
|
|
|
:octicons-beaker-24: Experimental
|
2020-12-13 18:41:18 +03:00
|
|
|
|
|
|
|
|
|
When _sticky tabs_ are enabled, navigation tabs will lock below the header and
|
|
|
|
|
always remain visible when scrolling down. Just add the following two feature
|
|
|
|
|
flags to `mkdocs.yml`:
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
features:
|
|
|
|
|
- navigation.tabs
|
|
|
|
|
- navigation.tabs.sticky
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
=== "With sticky tabs"
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[![With sticky tabs][11]][11]
|
2020-12-13 18:41:18 +03:00
|
|
|
|
|
|
|
|
|
=== "Without sticky tabs"
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[![Without sticky tabs][12]][12]
|
2020-12-13 18:41:18 +03:00
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[10]: https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/header.html
|
|
|
|
|
[11]: ../assets/screenshots/navigation-tabs-sticky.png
|
|
|
|
|
[12]: ../assets/screenshots/navigation-tabs-collapsed.png
|
2020-12-13 18:41:18 +03:00
|
|
|
|
|
2020-11-01 17:43:26 +03:00
|
|
|
|
### Navigation sections
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[:octicons-file-code-24: Source][13] ·
|
2020-12-21 19:38:58 +03:00
|
|
|
|
:octicons-unlock-24: Feature flag
|
2020-11-01 17:43:26 +03:00
|
|
|
|
|
|
|
|
|
When _sections_ are enabled, top-level sections are rendered as groups in the
|
2021-01-31 21:23:28 +03:00
|
|
|
|
sidebar for viewports above `1220px`, but remain as-is on mobile. Add the
|
|
|
|
|
following lines to `mkdocs.yml`:
|
2020-11-01 17:43:26 +03:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
features:
|
|
|
|
|
- navigation.sections
|
|
|
|
|
```
|
|
|
|
|
|
2020-11-07 20:01:46 +03:00
|
|
|
|
=== "With sections"
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[![With sections][14]][14]
|
2020-11-07 20:01:46 +03:00
|
|
|
|
|
|
|
|
|
=== "Without sections"
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[![Without sections][9]][9]
|
2020-11-07 20:01:46 +03:00
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[13]: https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/nav-item.html
|
|
|
|
|
[14]: ../assets/screenshots/navigation-sections.png
|
2020-11-07 20:01:46 +03:00
|
|
|
|
|
2020-11-01 17:43:26 +03:00
|
|
|
|
Both feature flags, _tabs_ and _sections_, can be combined with each other. If
|
2020-12-21 19:38:58 +03:00
|
|
|
|
both feature flags are enabled, sections are rendered for level 2 navigation
|
2020-11-01 17:43:26 +03:00
|
|
|
|
items.
|
|
|
|
|
|
|
|
|
|
### Navigation expansion
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[:octicons-file-code-24: Source][13] ·
|
2020-12-21 19:38:58 +03:00
|
|
|
|
:octicons-unlock-24: Feature flag
|
2020-11-01 17:43:26 +03:00
|
|
|
|
|
|
|
|
|
When _expansion_ is enabled, the left sidebar will expand all collapsible
|
|
|
|
|
subsections by default, so the user doesn't have to open subsections manually.
|
2021-01-31 21:23:28 +03:00
|
|
|
|
Add the following lines to `mkdocs.yml`:
|
2020-11-01 17:43:26 +03:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
features:
|
|
|
|
|
- navigation.expand
|
|
|
|
|
```
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
2020-11-07 20:01:46 +03:00
|
|
|
|
=== "With expansion"
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[![With expansion][15]][15]
|
2020-11-07 20:01:46 +03:00
|
|
|
|
|
|
|
|
|
=== "Without expansion"
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[![Without expansion][9]][9]
|
2020-11-07 20:01:46 +03:00
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[15]: ../assets/screenshots/navigation-expand.png
|
2020-11-07 20:01:46 +03:00
|
|
|
|
|
2021-01-31 18:30:57 +03:00
|
|
|
|
### Section index pages
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[:octicons-file-code-24: Source][16] ·
|
2021-01-31 18:30:57 +03:00
|
|
|
|
:octicons-unlock-24: Feature flag ·
|
2021-09-23 10:23:42 +03:00
|
|
|
|
:octicons-beaker-24: Experimental
|
2021-01-31 18:30:57 +03:00
|
|
|
|
|
2021-01-31 20:51:49 +03:00
|
|
|
|
When _section index pages_ are enabled, documents can be directly attached to
|
2021-01-31 21:23:28 +03:00
|
|
|
|
sections, which is particularly useful for providing overview pages. Add the
|
|
|
|
|
following lines to `mkdocs.yml`:
|
2021-01-31 18:30:57 +03:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
features:
|
|
|
|
|
- navigation.indexes
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
=== "With section index pages"
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[![With expansion][17]][17]
|
2021-01-31 18:30:57 +03:00
|
|
|
|
|
|
|
|
|
=== "Without section index pages"
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[![Without expansion][18]][18]
|
2021-01-31 18:30:57 +03:00
|
|
|
|
|
2021-01-31 20:51:49 +03:00
|
|
|
|
In order to link a page to a section, create a new document with the name
|
|
|
|
|
`index.md` in the respective folder, and add it to the beginning of your
|
|
|
|
|
navigation section:
|
2021-01-31 18:30:57 +03:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
nav:
|
|
|
|
|
- Section:
|
|
|
|
|
- section/index.md
|
|
|
|
|
- Page 1: section/page-1.md
|
|
|
|
|
...
|
|
|
|
|
- Page n: section/page-n.md
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
_This feature flag can be combined with all other feature flags, e.g. [tabs][1]
|
2021-09-23 10:23:42 +03:00
|
|
|
|
and [sections][2], except for table of contents [navigation integration][19]._
|
2021-01-31 18:30:57 +03:00
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[16]: https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/nav-item.html
|
|
|
|
|
[17]: ../assets/screenshots/navigation-index-on.png
|
|
|
|
|
[18]: ../assets/screenshots/navigation-index-off.png
|
|
|
|
|
[19]: #navigation-integration
|
2021-01-31 18:30:57 +03:00
|
|
|
|
|
2021-03-13 16:28:43 +03:00
|
|
|
|
### Back-to-top button
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[:octicons-file-code-24: Source][20] ·
|
2021-03-29 19:59:53 +03:00
|
|
|
|
:octicons-unlock-24: Feature flag
|
2021-03-13 16:28:43 +03:00
|
|
|
|
|
|
|
|
|
A _back-to-top button_ can be shown when the user, after scrolling down, starts
|
2021-07-03 16:03:54 +03:00
|
|
|
|
to scroll up again. It's rendered centered and just below the header. Add the
|
|
|
|
|
following lines to `mkdocs.yml`:
|
2021-03-13 16:28:43 +03:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
features:
|
|
|
|
|
- navigation.top
|
|
|
|
|
```
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[![back-to-top button][21]][21]
|
2021-03-13 16:28:43 +03:00
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[20]: https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/stylesheets/main/layout/_top.scss
|
|
|
|
|
[21]: ../assets/screenshots/back-to-top.png
|
2021-03-13 16:28:43 +03:00
|
|
|
|
|
2020-07-17 14:08:27 +03:00
|
|
|
|
### Table of contents
|
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
[:octicons-file-code-24: Source][22] · [:octicons-workflow-24: Extension][23]
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
The [Table of contents][24] extension, which is part of the standard Markdown
|
2020-07-17 14:08:27 +03:00
|
|
|
|
library, provides some options that are supported by Material for MkDocs to
|
2020-07-17 15:33:52 +03:00
|
|
|
|
customize its appearance:
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
2021-03-13 16:30:29 +03:00
|
|
|
|
`permalink`{ #permalink }
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
2020-07-20 16:18:09 +03:00
|
|
|
|
: :octicons-milestone-24: Default: `false` – This option adds an anchor link
|
|
|
|
|
containing the paragraph symbol `¶` or another custom symbol at the end of
|
|
|
|
|
each headline, exactly like on the page you're currently viewing, which
|
|
|
|
|
Material for MkDocs will make appear on hover:
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
|
|
|
|
=== "¶"
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
markdown_extensions:
|
|
|
|
|
- toc:
|
|
|
|
|
permalink: true
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
=== "⚓︎"
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
markdown_extensions:
|
|
|
|
|
- toc:
|
|
|
|
|
permalink: ⚓︎
|
|
|
|
|
```
|
|
|
|
|
|
2021-03-13 16:30:29 +03:00
|
|
|
|
`slugify`{ #slugify }
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
2020-07-20 16:18:09 +03:00
|
|
|
|
: :octicons-milestone-24: Default: `headerid.slugify` – This option allows for
|
|
|
|
|
customization of the slug function. For some languages, the default may not
|
2020-12-21 19:38:58 +03:00
|
|
|
|
produce good and readable identifiers – consider using another slug function
|
2021-09-23 10:23:42 +03:00
|
|
|
|
like for example those from [Python Markdown Extensions][25]:
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
|
|
|
|
=== "Unicode"
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
markdown_extensions:
|
|
|
|
|
- toc:
|
2020-09-06 12:49:05 +03:00
|
|
|
|
slugify: !!python/name:pymdownx.slugs.uslugify
|
2020-07-17 14:08:27 +03:00
|
|
|
|
```
|
|
|
|
|
|
2020-07-17 15:33:52 +03:00
|
|
|
|
=== "Unicode, case-sensitive"
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
markdown_extensions:
|
|
|
|
|
- toc:
|
2020-09-06 12:49:05 +03:00
|
|
|
|
slugify: !!python/name:pymdownx.slugs.uslugify_cased
|
2020-07-17 14:08:27 +03:00
|
|
|
|
```
|
|
|
|
|
|
2021-03-13 16:30:29 +03:00
|
|
|
|
`toc_depth`{ #toc_depth }
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
2020-07-20 16:18:09 +03:00
|
|
|
|
: :octicons-milestone-24: Default: `6` – Define the range of levels to be
|
|
|
|
|
included in the table of contents. This may be useful for project
|
|
|
|
|
documentation with deeply structured headings to decrease the length of the
|
|
|
|
|
table of contents, or to remove the table of contents altogether:
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
|
|
|
|
=== "Hide levels 4-6"
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
markdown_extensions:
|
|
|
|
|
- toc:
|
|
|
|
|
toc_depth: 3
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
=== "Hide table of contents"
|
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
markdown_extensions:
|
|
|
|
|
- toc:
|
|
|
|
|
toc_depth: 0
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
_Material for MkDocs doesn't provide official support for the other options of
|
2021-03-21 19:14:32 +03:00
|
|
|
|
this extension, so they may be supported but might yield unexpected results.
|
|
|
|
|
Use them at your own risk._
|
2020-07-17 14:08:27 +03:00
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
[22]: https://github.com/squidfunk/mkdocs-material/blob/master/src/partials/toc.html
|
|
|
|
|
[23]: https://python-markdown.github.io/extensions/toc/
|
|
|
|
|
[24]: https://python-markdown.github.io/extensions/toc/#usage
|
|
|
|
|
[25]: https://facelessuser.github.io/pymdown-extensions/extras/slugs/
|
2020-09-19 17:55:20 +03:00
|
|
|
|
|
2020-11-15 17:34:44 +03:00
|
|
|
|
#### Navigation integration
|
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
[:octicons-file-code-24: Source][26] ·
|
2020-12-21 19:38:58 +03:00
|
|
|
|
:octicons-unlock-24: Feature flag
|
2020-11-15 17:34:44 +03:00
|
|
|
|
|
|
|
|
|
When _integration_ is enabled, the table of contents is rendered as part of
|
2021-01-31 21:23:28 +03:00
|
|
|
|
the navigation for viewports above `1220px`, but remains as-is on mobile. Add
|
|
|
|
|
the following lines to `mkdocs.yml`:
|
2020-11-15 17:34:44 +03:00
|
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
|
theme:
|
|
|
|
|
features:
|
|
|
|
|
- toc.integrate
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
=== "Integrate table of contents"
|
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
[![Integrate table of contents][27]][27]
|
2020-11-15 17:34:44 +03:00
|
|
|
|
|
|
|
|
|
=== "Separate table of contents"
|
|
|
|
|
|
2021-09-23 10:23:42 +03:00
|
|
|
|
[![Separate table of contents][8]][8]
|
2020-11-15 17:34:44 +03:00
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
[26]: https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/stylesheets/main/layout/_nav.scss
|
|
|
|
|
[27]: ../assets/screenshots/toc-integrate.png
|
2020-11-15 17:34:44 +03:00
|
|
|
|
|
|
|
|
|
The content section will now always stretch to the right side, resulting in
|
|
|
|
|
more space for your content. This feature flag can be combined with all other
|
|
|
|
|
feature flags, e.g. [tabs][1] and [sections][2].
|
|
|
|
|
|
2021-05-01 18:53:39 +03:00
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
|
|
### Hiding the sidebars
|
2020-09-19 17:55:20 +03:00
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
[:octicons-file-code-24: Source][28] ·
|
2020-12-21 19:38:58 +03:00
|
|
|
|
:octicons-note-24: Metadata
|
2020-09-19 17:55:20 +03:00
|
|
|
|
|
2020-11-07 20:18:22 +03:00
|
|
|
|
Sometimes it's desirable to hide the navigation and/or table of contents
|
|
|
|
|
sidebar, especially when there's a single navigation item. This can be done for
|
2021-03-29 19:59:53 +03:00
|
|
|
|
any page using the [Metadata][29] extension:
|
2020-09-19 17:55:20 +03:00
|
|
|
|
|
2021-05-30 16:59:13 +03:00
|
|
|
|
``` bash
|
2020-11-07 20:01:46 +03:00
|
|
|
|
---
|
|
|
|
|
hide:
|
2021-05-30 16:59:13 +03:00
|
|
|
|
- navigation
|
|
|
|
|
- toc
|
2020-11-07 20:01:46 +03:00
|
|
|
|
---
|
|
|
|
|
|
2021-05-30 16:59:13 +03:00
|
|
|
|
# Document title
|
2020-11-07 20:01:46 +03:00
|
|
|
|
...
|
2020-09-19 17:55:20 +03:00
|
|
|
|
```
|
|
|
|
|
|
2020-11-07 20:01:46 +03:00
|
|
|
|
=== "Hide navigation"
|
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
[![Hide navigation][30]][30]
|
2020-11-07 20:01:46 +03:00
|
|
|
|
|
|
|
|
|
=== "Hide table of contents"
|
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
[![Hide table of contents][31]][31]
|
2020-11-07 20:01:46 +03:00
|
|
|
|
|
|
|
|
|
=== "Hide both"
|
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
[![Hide navigation and table of contents][32]][32]
|
2020-11-07 20:01:46 +03:00
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
[28]: https://github.com/squidfunk/mkdocs-material/blob/master/src/base.html
|
|
|
|
|
[29]: ../../reference/meta-tags/#metadata
|
|
|
|
|
[30]: ../assets/screenshots/hide-navigation.png
|
|
|
|
|
[31]: ../assets/screenshots/hide-toc.png
|
|
|
|
|
[32]: ../assets/screenshots/hide-navigation-toc.png
|
2020-11-07 20:01:46 +03:00
|
|
|
|
|
2020-07-23 14:17:50 +03:00
|
|
|
|
## Customization
|
|
|
|
|
|
|
|
|
|
### Keyboard shortcuts
|
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
[:octicons-file-code-24: Source][33] ·
|
2020-07-23 14:17:50 +03:00
|
|
|
|
:octicons-mortar-board-24: Difficulty: _easy_
|
|
|
|
|
|
|
|
|
|
Material for MkDocs includes several keyboard shortcuts that make it possible
|
|
|
|
|
to navigate your project documentation via keyboard. There're two modes:
|
|
|
|
|
|
2021-03-13 16:30:29 +03:00
|
|
|
|
`search`{ #search }
|
2020-07-23 14:17:50 +03:00
|
|
|
|
|
|
|
|
|
: This mode is active when the _search is focused_. It provides several key
|
|
|
|
|
bindings to make search accessible and navigable via keyboard:
|
|
|
|
|
|
2020-07-27 13:05:07 +03:00
|
|
|
|
* ++arrow-down++ , ++arrow-up++ : select next / previous result
|
|
|
|
|
* ++esc++ , ++tab++ : close search dialog
|
|
|
|
|
* ++enter++ : follow selected result
|
2020-07-23 14:17:50 +03:00
|
|
|
|
|
2021-03-13 16:30:29 +03:00
|
|
|
|
`global`{ #global }
|
2020-07-23 14:17:50 +03:00
|
|
|
|
|
2020-07-26 15:46:09 +03:00
|
|
|
|
: This mode is active when _search is not focussed_ and when there's no other
|
|
|
|
|
focussed element that is susceptible to keyboard input. The following keys
|
|
|
|
|
are bound:
|
2020-07-23 14:17:50 +03:00
|
|
|
|
|
2020-07-27 13:05:07 +03:00
|
|
|
|
* ++f++ , ++s++ , ++slash++ : open search dialog
|
|
|
|
|
* ++p++ , ++comma++ : go to previous page
|
|
|
|
|
* ++n++ , ++period++ : go to next page
|
2020-07-23 14:17:50 +03:00
|
|
|
|
|
|
|
|
|
Let's say you want to bind some action to the ++x++ key. By using [additional
|
2021-03-29 19:59:53 +03:00
|
|
|
|
JavaScript][34], you can subscribe to the `keyboard$` observable and attach
|
2020-07-23 14:17:50 +03:00
|
|
|
|
your custom event listener:
|
|
|
|
|
|
|
|
|
|
``` js
|
2021-02-23 00:27:30 +03:00
|
|
|
|
keyboard$.subscribe(function(key) {
|
2020-07-23 14:17:50 +03:00
|
|
|
|
if (key.mode === "global" && key.type === "x") {
|
|
|
|
|
/* Add custom keyboard handler here */
|
|
|
|
|
key.claim()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The call to `#!js key.claim()` will essentially execute `#!js preventDefault()`
|
2020-07-26 15:46:09 +03:00
|
|
|
|
on the underlying event, so the keypress will not propagate further and touch
|
2020-07-23 14:17:50 +03:00
|
|
|
|
other event listeners.
|
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
[33]: https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/keyboard/index.ts
|
|
|
|
|
[34]: ../customization.md#additional-javascript
|
2020-11-15 17:34:44 +03:00
|
|
|
|
|
|
|
|
|
### Content area width
|
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
[:octicons-file-code-24: Source][35] ·
|
2020-11-15 17:34:44 +03:00
|
|
|
|
:octicons-mortar-board-24: Difficulty: _easy_
|
|
|
|
|
|
|
|
|
|
The width of the content area is set so the length of each line doesn't exceed
|
|
|
|
|
80-100 characters, depending on the width of the characters. While this
|
|
|
|
|
is a reasonable default, as longer lines tend to be harder to read, it may be
|
|
|
|
|
desirable to increase the overall width of the content area, or even make it
|
|
|
|
|
stretch to the entire available space.
|
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
This can easily be achieved with an [additional stylesheet][36] and a few lines
|
2020-11-15 17:34:44 +03:00
|
|
|
|
of CSS:
|
|
|
|
|
|
|
|
|
|
=== "Increase width"
|
|
|
|
|
|
|
|
|
|
``` css
|
|
|
|
|
.md-grid {
|
|
|
|
|
max-width: 1440px;
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
=== "Stretch to fit"
|
|
|
|
|
|
|
|
|
|
``` css
|
|
|
|
|
.md-grid {
|
|
|
|
|
max-width: initial;
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2021-03-29 19:59:53 +03:00
|
|
|
|
[35]: https://github.com/squidfunk/mkdocs-material/blob/aeaa00a625abf952f355164de02c539b061e6127/src/assets/stylesheets/main/layout/_base.scss
|
|
|
|
|
[36]: ../customization.md#additional-css
|