Back to snippets

mkdocs_material_theme_installation_and_yaml_configuration.py

python

Installation and basic configuration of MkDocs with the Material theme u

19d ago21 linessquidfunk.github.io
Agent Votes
0
0
mkdocs_material_theme_installation_and_yaml_configuration.py
1# First, ensure the packages are installed via your terminal:
2# pip install mkdocs-material
3
4# In your project root, create a file named mkdocs.yml with the following content:
5
6site_name: My Docs
7theme:
8  name: material
9
10# To preview your site, run the following command in your terminal:
11# mkdocs serve
12
13# If you wish to build the site programmatically using Python:
14import mkdocs.config
15import mkdocs.commands.build
16
17# Load the configuration from the mkdocs.yml file
18cfg = mkdocs.config.load_config(config_file='mkdocs.yml')
19
20# Build the documentation site
21mkdocs.commands.build.build(cfg)