Skip to content

采用Material主题

Material for MkDocs

Documentation that simply works

Material for MkDocs is a powerful documentation framework on top of MkDocs, a static site generator for project documentation.

安装 mkdocs-material#

Getting started - Installation

$ pip install mkdocs-material
# or 
$ pip3 install mkdocs-material
# or 
$ python3 -m pip install mkdocs-material

设置主题为 material#

Getting started - Creating your site - Configuration

Minimal configuration

在 mkdocs.yml 配置文件中,指定主题 material,替换默认的 mkdocs 主题:

# 指定主题
theme:
  name: material

Setup & Customization#

Advanced configuration:

Material for MkDocs comes with many configuration options. The Setup section explains in great detail how to configure and customize colors, fonts, icons and much more

  1. Site structure
  2. Appearance
  3. Content
  4. Optimization

Getting started - Customization

  1. Adding assets
  2. Extending the theme
  3. Theme development

MkDocs Material Preview#

MkDocs Material Preview - Visual Studio Marketplace: A VS Code extension that enhances the built-in Markdown preview to render Material for MkDocs and Zensical components that are not supported by the default Markdown renderer.

它通过附加插件来扩展 VS Code 内置的 Markdown 解析器--markdown-it,从而增强支持渲染/预览以下 Material 特性组件:

  • Admonitions!!! type "title" (standard), ??? type (collapsible), ???+ type (collapsible, open)
  • Content Tabs=== "Tab Title" with CSS-only tab switching
  • Code Enhancementstitle="file.py", hl_lines="2 4-6", linenums="1" on fenced code blocks

它是预览 Material for MkDocs/Zensical 语法最高效的方式,无需任何配置步骤,只需打开预览界面即可使用。

The relevant commands in Command Pallete are as follows:

  1. Markdown: Toggle Preview View
  2. Markdown: Open Preview to the Side
  3. Markdown: Open Preview
  4. Markdown: Switch to Preview View

参考借鉴#

Stackoverflow - Questions tagged mkdocs-material

Migrating my blog from Jekyll Minimal Mistakes to Mkdocs Material @github

claassen.net - Blogging with mkdocs

使用 MkDocs 和 Material 主题搭建技术博客 @github

基于 Material for MkDocs 搭建静态网页 @github

把博客生成器从 Hugo 迁移到 Mkdocs @github

Mkdocs Material使用记录 - 详尽记录 @github

快来美化你的MKDocs吧 - material 配置

Material for MkDocs改动的几个地方

Comments