Skip to content

MKDOCS

  • Overview
  • Start
  • Setup
  • Reference

Overview

MKDocs is a static site generator that's geared specifically for project documentation. With MKDocs, you can create a documentation site using plain Markdown files, and the site's structure and navigation are created based on your directory structure. It's incredibly lightweight and doesn't require a database like MongoDB or a backend framework like FastAPI since it generates static HTML files.

Start

  • START: install > create site > publish site > customisation

  • pip install mkdocs-material

  • mkdocs new [dir-name] - Create a new project.
  • mkdocs serve - Start the live-reloading docs server.
  • mkdocs build - Build the documentation site.
  • mkdocs -h - Print help message and exit.

DOCS

  • CD to folder cd CHEAT
  • Create venv python3 -m venv venv
  • Activate venv source venv/bin/activate
  • Install mkdocs-material pip install mkdocs-material
  • Create a new project: mkdocs new [dir-name]
  • mkdocs serve - Start the live-reloading docs server.
  • mkdocs build - Build the documentation site.
  • mkdocs -h - Print help message and exit.
# VENV
cd ~/CHEAT/
python3 -m venv venv
source venv/bin/activate

# MKDOCS
pip install mkdocs-material
mkdocs new docs
cd docs
mkdocs serve
mkdocs serve -a localhost:8001
mkdocs build

Setup

theme:
  palette:
    scheme: slate

Reference

Project layout

mkdocs.yml    # The configuration file.
docs/
    index.md  # The documentation homepage.
    ...       # Other markdown pages, images and other files.

CSS

.
├─ docs/
│  └─ stylesheets/
│     └─ extra.css
└─ mkdocs.yml

js

.
├─ docs/
│  └─ javascripts/
│     └─ extra.js
└─ mkdocs.yml

and in mkdcos.yml

extra_javascript:
- javascripts/extra.js

Enable checkbox

markdown_extensions: - pymdownx.tasklist: custom_checkbox: true