Skip to content

<< [[2024-06-02]] | [[2024-06-04]] >>

1 如何用mkdocs+GitHubPages搭建自己的博客系统

[!quote] Imagination is more important than knowledge. For while knowledge defines all we currently know and understand, imagination points to all we might yet discover and create. — Albert Einstein

前言:

1.1 创建一个 blog

mkdocs.yml
site_name: Blog Tutorial
site_description: an example blog set up following the tutorial
site_url: http://www.example.com

theme:
  name: material

plugins:
  - search
  - blog

docs ├── blog │   ├── index.md │   └── posts └── index.md

1.2 如何在md中创建一个tab选项呢?语法是什么?

==="Unix, Powershell"

docker run --rm -it -v ${PWD}:/docs suidfunk/mkdocs-material new .

==="Windows(cmd)"

docker run --rm -it -v "%cd%":/docs suidfunk/mkdocs-material new .

1.3 Installation

Material for MkDocs is published as a [Python package] and can be installed with pip, ideally by using a [virtual environment]. Open up a terminal and install Material for MkDocs with:

=== "Latest"

pip install mkdocs-material

=== "9.x"

pip install mkdocs-material=="9.*" # (1)!
  1. Material for MkDocs uses [semantic versioning][^2], which is why it's a good idea to limit upgrades to the current major version.

    This will make sure that you don't accidentally [upgrade to the next major version], which may include breaking changes that silently corrupt your site. Additionally, you can use pip freeze to create a lockfile, so builds are reproducible at all times:

    pip freeze > requirements.txt

    Now, the lockfile can be used for installation: