使用 MkDocs 创建简单网站
推荐访问个人博客,以获得更好的阅读体验
地址:https://www.cristime.top/index.php/archives/6/
一、主要步骤
-
安装 MkDocs
sudo apt install python3 python3-pip # 配置好 python3 环境的可省略 pip3 install mkdocs
-
使用
mkdocs new YOUR_SITE_NAME # 创建网站项目 cd YOUR_SITE_NAME
此时,这个目录应该是如下结构:
├── docs │ └── index.md └── mkdocs.yml
其中,docs 目录是文档和其他资源存储的目录,mkdocs.yml 是配置文件。
若要创建新文档,在 docs 目录中新建 MarkDown 文件并在 mkdocs.yml 中配置,可参考 MkDocs 文档
mkdocs build # 生成静态网页(在 site 目录) mkdocs serve # 预览网页( https://localhost:8000
-
美化
pip3 install mkdocs-material # 安装 material 主题
material 主题的具体使用参见 Material 主题文档
二、部署网站
-
使用 GitHub Pages/Gitee Pages
git init # git branch -m main git add . && git commit -m "MESSAGE" git remote add origin YOUR_SERVER_URL git push -u origin master # 或者是 git push -u origin main
-
部署时请部署 site 目录