{"id":13500888,"url":"https://github.com/danielfrg/mkdocs-jupyter","last_synced_at":"2025-05-14T11:10:22.874Z","repository":{"id":36579383,"uuid":"228738520","full_name":"danielfrg/mkdocs-jupyter","owner":"danielfrg","description":"Use Jupyter Notebook in mkdocs","archived":false,"fork":false,"pushed_at":"2025-02-21T03:41:52.000Z","size":13039,"stargazers_count":442,"open_issues_count":43,"forks_count":55,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-13T21:49:47.809Z","etag":null,"topics":["blogging","documentation","jupyter","jupyter-notebook","mkdocs"],"latest_commit_sha":null,"homepage":"https://mkdocs-jupyter.danielfrg.com","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielfrg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","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}},"created_at":"2019-12-18T02:11:34.000Z","updated_at":"2025-05-09T16:38:00.000Z","dependencies_parsed_at":"2023-01-17T03:00:40.956Z","dependency_job_id":"f25ceafc-0cc0-4ef3-acc6-d8350370faaf","html_url":"https://github.com/danielfrg/mkdocs-jupyter","commit_stats":{"total_commits":246,"total_committers":31,"mean_commits":7.935483870967742,"dds":"0.30487804878048785","last_synced_commit":"d72a84a96d6a39cdf178c0d671d46b2b52f28aa9"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfrg%2Fmkdocs-jupyter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfrg%2Fmkdocs-jupyter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfrg%2Fmkdocs-jupyter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielfrg%2Fmkdocs-jupyter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielfrg","download_url":"https://codeload.github.com/danielfrg/mkdocs-jupyter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254129489,"owners_count":22019628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["blogging","documentation","jupyter","jupyter-notebook","mkdocs"],"created_at":"2024-07-31T22:01:18.136Z","updated_at":"2025-05-14T11:10:22.832Z","avatar_url":"https://github.com/danielfrg.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook","Notebook Sharing \u0026 Conversion","Jupyter-Notebook分享与格式转换"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/danielfrg/mkdocs-jupyter/main/docs/logo.png\" width=\"450px\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://pypi.org/project/mkdocs-jupyter/\"\u003e\n        \u003cimg src=\"https://img.shields.io/pypi/v/mkdocs-jupyter.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pypi.org/project/mkdocs-jupyter/\"\u003e\n        \u003cimg src=\"https://img.shields.io/pypi/pyversions/mkdocs-jupyter.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/danielfrg/mkdocs-jupyter/actions/workflows/test.yml\"\u003e\n        \u003cimg src=\"https://github.com/danielfrg/mkdocs-jupyter/workflows/test/badge.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://codecov.io/gh/danielfrg/mkdocs-jupyter?branch=main\"\u003e\n        \u003cimg src=\"https://codecov.io/gh/danielfrg/mkdocs-jupyter/branch/main/graph/badge.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"http://github.com/danielfrg/mkdocs-jupyter/blob/main/LICENSE.txt\"\u003e\n        \u003cimg src=\"https://img.shields.io/:license-Apache%202-blue.svg\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n# mkdocs-jupyter: Use Jupyter Notebooks in mkdocs\n\n-   [Docs demo Site](https://mkdocs-jupyter.danielfrg.com/)\n-   Add Jupyter Notebooks directly to the mkdocs navigation\n-   Support for multiple formats:\n    -   `.ipynb` and `.py` files (using\n        [jupytext](https://github.com/mwouts/jupytext))\n-   Same style as regular Jupyter Notebooks\n    -   Support Jupyter Themes\n-   Option to execute the notebook before converting\n-   Support for [ipywidgets](https://github.com/jupyter-widgets/ipywidgets)\n-   Support for mkdocs TOC\n-   Option to include notebook source\n\n\u003ca\nhref=\"https://raw.githubusercontent.com/danielfrg/mkdocs-jupyter/master/docs/mkdocs-theme.png\"\u003e\u003cimg\nsrc=\"https://raw.githubusercontent.com/danielfrg/mkdocs-jupyter/master/docs/mkdocs-theme.png\"\nalt=\"mkdocs-jupyter default theme\"  width=\"300\"\u003e\u003c/a\u003e \u003ca\nhref=\"https://raw.githubusercontent.com/danielfrg/mkdocs-jupyter/master/docs/material-theme.png\"\u003e\u003cimg\nsrc=\"https://raw.githubusercontent.com/danielfrg/mkdocs-jupyter/master/docs/material-theme.png\"\nalt=\"mkdocs-jupyter material theme\"  width=\"300\"\u003e\u003c/a\u003e\n\n## Installation\n\n```shell\npip install mkdocs-jupyter\n```\n\n## Configuration\n\nIn the `mkdocs.yml` use Jupyter notebooks (`.ipynb`) or Python scripts (`.py`)\nas pages:\n\n```yaml\nnav:\n    - Home: index.md\n    - Notebook page: notebook.ipynb\n    - Python file: python_script.py\nplugins:\n    - mkdocs-jupyter\n```\n\n### Titles and Table of Contents\n\nThe first h1 header (`#`) in your notebook will be used as the title.\n\n```md\n# This H1 header will be the the title.\n```\n\nThis can be turned off in the configuration (in which case the filename will be\nused as title):\n\n```yaml\nplugins:\n    - mkdocs-jupyter:\n          ignore_h1_titles: True\n```\n\nIn order to see the table of contents you need to maintain a hierarchical\nheaders structure in your notebooks. You must use h2 headers (`##`) and not h1\n(`#`)\n\n```md\n## This H2 title will show in the table of contents\n```\n\nIf you want to **nest headers** in the TOC you need to add additional levels\nlater in the same markdown cell or new bottom markdown cells:\n\n```md\n## This header will show as top level in the table of contents\n\n\u003ccontent\u003e\n\n### This one will be displayed inside the above level\n```\n\n### Including or Ignoring Files\n\nYou can control which files are included or ignored via lists of glob patterns:\n\n```yaml\nplugins:\n    - mkdocs-jupyter:\n          include: [\"*.ipynb\"] # Default: [\"*.py\", \"*.ipynb\"]\n          ignore: [\"some-irrelevant-files/*.ipynb\"]\n```\n\n### Execute Notebook\n\nYou can tell the plugin to execute the notebook before converting, default is\n`False`:\n\n```yaml\nplugins:\n    - mkdocs-jupyter:\n          execute: true\n```\n\nYou can tell the plugin to ignore the execution of some files (with glob\nmatching):\n\n```yaml\nplugins:\n    - mkdocs-jupyter:\n          execute_ignore:\n              - \"my-secret-files/*.ipynb\"\n```\n\nTo fail when notebook execution fails set `allow_errors` to `false`:\n\n```yaml\nplugins:\n    - mkdocs-jupyter:\n          execute: true\n          allow_errors: false\n```\n\n#### Kernel\n\nBy default the plugin will use the kernel specified in the notebook to execute\nit. You can specify a custom kernel name to use for all the notebooks:\n\n```yaml\nplugins:\n    - mkdocs-jupyter:\n          kernel_name: python3\n```\n\n### Ignore Code Input\n\nBy default the plugin will show full code and regular cell output details. You\ncan hide cell code input for all the notebooks:\n\n```yaml\nplugins:\n    - mkdocs-jupyter:\n          show_input: False\n```\n\nYou can also decide to hide the `Out[#]` output notation and other cell metadata\nfor all the notebooks:\n\n```yaml\nplugins:\n    - mkdocs-jupyter:\n          no_input: True\n```\n\n### Remove Cell Using Tags\n\nBy default the plugin will show full code and regular cell output details. You\ncan hide cell code input for specific cells using tags:\n\n```yaml\nplugins:\n    - mkdocs-jupyter:\n          remove_tag_config:\n              remove_input_tags:\n                  - hide_code\n```\n\nMore detailed on removing cell based on tag, see [NbConvert\nCustomization](https://nbconvert.readthedocs.io/en/latest/removing_cells.html))\n\n### Jupyter themes\n\nYou can configure the different Jupyter themes. For example if using material\nwith `slate` color scheme you can use the Jupyter Lab `dark` theme:\n\n```yml\nplugins:\n    - mkdocs-jupyter:\n          theme: dark\n\ntheme:\n    name: material\n    palette:\n        scheme: slate\n```\n\n### Extra CSS classes\n\nThis option will add a custom CSS class to the `div` container that highlights\nthe code cells. This can be useful to add custom styles to the code cells.\n\n```yml\nplugins:\n  - mkdocs-jupyter:\n      highlight_extra_classes: \"custom-css-classes\n```\n\n### RequireJS\n\nBy default RequireJS is not loaded. This is required for Plotly.\nYou can enable it with:\n\n```yml\nplugins:\n    - mkdocs-jupyter:\n          include_requirejs: true\n```\n\n### Download notebook link\n\nYou can tell the plugin to include the notebook source to make it easy to show a\ndownload button in the theme, default is `False`:\n\n```yml\nplugins:\n    - mkdocs-jupyter:\n          include_source: True\n```\n\nThis setting will also create a `page.nb_url` value that you can use in your\ntheme to make a link in each page.\n\nFor example in `mkdocs-material` (see\n[customization](https://squidfunk.github.io/mkdocs-material/customization/#overriding-template-blocks)),\nyou can create a `main.html` file like this:\n\n```jinja\n{% extends \"base.html\" %}\n\n{% block content %}\n{% if page.nb_url %}\n    \u003ca href=\"{{ page.nb_url }}\" title=\"Download Notebook\" class=\"md-content__button md-icon\"\u003e\n        {% include \".icons/material/download.svg\" %}\n    \u003c/a\u003e\n{% endif %}\n\n{{ super() }}\n{% endblock content %}\n```\n\n![Download Notebook button](https://raw.githubusercontent.com/danielfrg/mkdocs-jupyter/master/docs/download-button.png)\n\n## Styles\n\nThis extensions includes the Jupyter Lab nbconvert CSS styles and does some\nmodifications to make it as generic as possible in order for it to work with a\nvariety of mkdocs themes. This is not always possible and the theme we test the\nmost is [mkdocs-material](https://squidfunk.github.io/mkdocs-material).\n\nIt's possible you might need to do some CSS changes to make it look as good as\nyou want, for example for the material theme take a look at their [customization\ndocs](https://squidfunk.github.io/mkdocs-material/customization/#overriding-template-blocks).\n\nCreate a `main.html` file like:\n\n```jinja\n{% extends \"base.html\" %}\n\n{% block content %}\n{{ super() }}\n\n\u003cstyle\u003e\n// Do whatever changes you need here\n\n.jp-RenderedHTMLCommon p {\n    color: red\n}\n\n\u003c/style\u003e\n{% endblock content %}\n```\n\n## Mkdocs Material notes\n\nAny markdown specific features such as\n[admonitions](https://squidfunk.github.io/mkdocs-material/reference/admonitions/)\nwon't work with mkdocs-jupyter because those features are not supported by\nJupyter itself and we use [nbconvert](https://nbconvert.readthedocs.io/) to make\nthe conversion.\n\nTo use this type of features you have to define the HTML directly in the\nmarkdown cells:\n\n```html\n\u003cdiv class=\"admonition note\"\u003e\n    \u003cp class=\"admonition-title\"\u003eNote\u003c/p\u003e\n    \u003cp\u003e\n        If two distributions are similar, then their entropies are similar,\n        implies the KL divergence with respect to two distributions will be\n        smaller...\n    \u003c/p\u003e\n\u003c/div\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielfrg%2Fmkdocs-jupyter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielfrg%2Fmkdocs-jupyter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielfrg%2Fmkdocs-jupyter/lists"}