{"id":22492501,"url":"https://github.com/six-two/mkdocs-toggle-sidebar-plugin","last_synced_at":"2026-03-06T22:04:44.674Z","repository":{"id":192429461,"uuid":"687136105","full_name":"six-two/mkdocs-toggle-sidebar-plugin","owner":"six-two","description":"Toggle the navigation and/or TOC sidebars on your MkDocs site","archived":false,"fork":false,"pushed_at":"2025-11-08T11:31:24.000Z","size":79,"stargazers_count":9,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-08T13:17:15.382Z","etag":null,"topics":["mkdocs","mkdocs-plugin"],"latest_commit_sha":null,"homepage":"https://mkdocs-toggle-sidebar.six-two.dev/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/six-two.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-09-04T17:41:57.000Z","updated_at":"2025-11-08T11:31:29.000Z","dependencies_parsed_at":"2024-08-23T19:04:38.314Z","dependency_job_id":"f94944e7-1386-4898-8052-2460852a3856","html_url":"https://github.com/six-two/mkdocs-toggle-sidebar-plugin","commit_stats":null,"previous_names":["six-two/mkdocs-toggle-sidebar-plugin"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/six-two/mkdocs-toggle-sidebar-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/six-two%2Fmkdocs-toggle-sidebar-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/six-two%2Fmkdocs-toggle-sidebar-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/six-two%2Fmkdocs-toggle-sidebar-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/six-two%2Fmkdocs-toggle-sidebar-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/six-two","download_url":"https://codeload.github.com/six-two/mkdocs-toggle-sidebar-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/six-two%2Fmkdocs-toggle-sidebar-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30200756,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"ssl_error","status_checked_at":"2026-03-06T18:57:34.882Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mkdocs","mkdocs-plugin"],"created_at":"2024-12-06T18:18:34.562Z","updated_at":"2026-03-06T22:04:39.658Z","avatar_url":"https://github.com/six-two.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mkdocs-toggle-sidebar-plugin\n\n[![PyPI version](https://img.shields.io/pypi/v/mkdocs-toggle-sidebar-plugin)](https://pypi.org/project/mkdocs-toggle-sidebar-plugin/)\n![License](https://img.shields.io/pypi/l/mkdocs-toggle-sidebar-plugin)\n![Python versions](https://img.shields.io/pypi/pyversions/mkdocs-toggle-sidebar-plugin)\n\nThis package allows you to toggle the left (navigation) and right (table of contents) sidebars on a couple of MkDocs themes such as:\n\n- [Material for MkDocs](https://github.com/squidfunk/mkdocs-material): `material`\n- Builtin themes: `mkdocs`, `readthedocs`\n\nYou can play around with it and these themes on the [test page](https://mkdocs-toggle-sidebar.six-two.dev).\n\nThe settings are stored using the `localStorage` object, so that it will persist between pages.\n\nI wrote it after getting frustrated by the browser's `Find in page` function matching way to many links in the navigation sidebar instead of searching in the actual page's content.\n\n\n## Usage\n\n### Setup\n\nFirst install the PyPI package:\n```bash\npip install mkdocs-toggle-sidebar-plugin\n```\n\nAdd something like the following to your `mkdocs.yml`:\n```yaml\nplugins:\n- search\n- toggle-sidebar\n```\n\n### Key bindings\n\nThe plugin adds the following key bindings:\n\nKey   | Action\n---   | ---\n`b` | toggle **b**oth (TOC and navigation)\n`m` | toggle navigation **m**enu\n`t` | toggle **T**OC\n\nFor some themes like `readthedocs` navigation and TOC are combined.\nIn this case the state of TOC is ignored, and only calls for navigation (or all) are interpreted.\n\n### Configuration options\n\nYou can overwrite the defaults like this:\n\n```yaml\nplugins:\n- search\n- toggle-sidebar:\n    async: False\n    debug: True\n    enabled: True\n    inline: False\n    javascript: ./toggle-sidebar.js\n    show_navigation_by_default: False\n    show_toc_by_default: False\n    theme: material\n    toggle_button: all\n```\n\nThe following options exist:\n\nOption | Type | Default value | Description\n--- | ---| --- | ---\nasync | `bool` | `False` | Asynchronously load the JavaScript file created by the plugin\ndebug | `bool` | `False` | Show some debug messages during mkdocs build (for example related to theme detection)\nenabled | `bool` | `True` | Can be used to disable the plugin. Usually used in combination with environment variables like `enabled: !ENV [TOGGLE_SIDEBAR, false]` as described in [mkdocs's docs](https://www.mkdocs.org/user-guide/configuration/#enabled-option)\ninline | `bool` | `False` | Instead of storing the javascript code in the file specified by `javascript`, it is directly copied into each page. Slightly increases page size, but can improve load times a little bit and reduce flickering on page (re-)load\njavascript | `str` | `\"assets/javascripts/toggle-sidebar.js\"` | The path where to store the output file\nshow_navigation_by_default | `bool` | `True` | Whether to show the navigation by default\nshow_toc_by_default | `bool` | `True` | Whether to show the table of contents by default\ntheme | `str` | `auto` | Used for theme detection. With `auto`, the plugin tries to automatically detect the theme. But you can also force it to use a specific theme preset that you know will work. Currently supported values: `material`/`ansible`, `mkdocs`, `readthedocs`.\ntoggle_button | `str` | `\"none\"` | Can be set to show a toggle button (see below)\n\n\n#### Toggle button\n\nWhen you set the `toggle_button` option to `navigation`, `toc` or `all`, it will add a button that looks like a hamburger menu (three horizontal bars) on a theme-dependent location.\nIt is usually in the nav or the top bar.\nClicking the button will toggle the navigation, table of contents, or both (depending on the supplied value).\nBy leaving the field empty or setting it to `none`, no button is added.\n\n### Exported API functions\n\nThis plugin exposes some JavaScript functions, that can show, hide or toggle the visibility of the sidebars.\nYou can see how they are called in `docs/javascript-functions.md` and how they are defined in `src/mkdocs_toggle_sidebar_plugin/toggle-sidebar.js`.\n\nIn short there are:\n\n- `MkdocsToggleSidebarPlugin.setNavigationVisibility(show: bool)`\n- `MkdocsToggleSidebarPlugin.setTocVisibility(show: bool)`\n- `MkdocsToggleSidebarPlugin.setAllVisibility: (showNavigation: bool, showTOC: bool)`\n- `MkdocsToggleSidebarPlugin.toggleNavigationVisibility()`\n- `MkdocsToggleSidebarPlugin.toggleTocVisibility()`\n- `MkdocsToggleSidebarPlugin.toggleAllVisibility()`\n\nThe names and parameters should be self-explanatory.\n\n## Theme support\n\nBelow shows the latest themes that I have tested.\nThe table is not updated regularly, but the plugin should generally work for other theme versions too.\n\nTheme            | Theme version | Plugin version | Status\n---              | ---           | ---            | ---\nmkdocs-ansible   | 25.6.0        | 0.0.6          | works\nmkdocs-material  | 9.6.14        | 0.0.4+         | works\nmkdocs (default) | 1.6.1         | 0.0.4+         | works\nreadthedocs      | 1.6.1         | 0.0.4+         | works\n\nJust open an issue / PR if you use a strange theme or the info above is not up-to-date anymore.\n\n### Note to self\n\nTest `material` theme:\n```bash\n./serve.sh\n```\n\nTest `mkdocs` theme:\n```bash\n./serve.sh --theme mkdocs\n```\n\nTest `mkdocs`, `readthedocs` and `material` themes:\n```bash\n./build.sh\npython3 -m http.server --directory './public/'\n```\n\nTest oldest python version supported by me (3.9):\n```bash\ndocker run --rm -it -v \"$PWD:/share\" -w \"/share\" -p 8000:8000 --entrypoint=bash python:3.9 ./serve.sh\n```\n\nTest newest available python version (currently 3.13):\n```bash\ndocker run --rm -it -v \"$PWD:/share\" -w \"/share\" -p 8000:8000 --entrypoint=bash python:latest ./serve.sh\n```\n\n\n## Notable changes\n\n### Version 0.0.6\n\n- Fixed toggle button appearing delayed on slow loading pages (see #6)\n- Fixed behavior when using Material's `navigation.instant` feature (see #5)\n- Added `inline` option that prevents page flickering on reload (see #4). It is now enabled by default and async is disabled by default, to prevent the flickering. To revert to the old behavior you can set `async: True` and `inline: False` in the plugin's config in your `mkdocs.yml`\n- Added `theme` option that allows you to override theme detection (see #3)\n- Added support for `ansible` theme (see #3)\n- Added fallback to check `theme.extra.base_theme` from `mkdocs.yml` when other theme detection logic fails (see #3)\n- Added `debug` option\n\n### Version 0.0.5\n\n- Bug fix: On small screens with the material theme the navigation would be hidden, even when the hamburger menu was opened.\n\n### Version 0.0.4\n\n- Export API via `MkdocsToggleSidebarPlugin` object.\n    This lets you create custom buttons or key bindings to hide, show or toggle the side bars.\n- Added `toggle_button` option and implemented it for Material theme.\n\n### Version 0.0.3\n\n- Changed internal API:\n    - Element hiding/restyling is now done via CSS, so it is easier to undo. You should no longer have problems on devices with small screens (like phones) having broken layouts.\n\n### Version 0.0.2\n\n- Added support for `mkdocs` and `readthedocs` theme.\n\n### Version 0.0.1\n\n- Prototype with `mkdocs-material` implementation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsix-two%2Fmkdocs-toggle-sidebar-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsix-two%2Fmkdocs-toggle-sidebar-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsix-two%2Fmkdocs-toggle-sidebar-plugin/lists"}