Install
pip install mkdocs-material
mkdocs作成
-
MKDocsの初期化
mkdocs new .
結果
tree . ├── docs │ └── index.md └── mkdocs.yml 1 directory, 2 files
-
テーマを
mkdocs.yml
で指定mkdocs.ymlsite_name: My Docs theme: name: material
-
ローカルで起動
mkdocs serve
-
ビルド
mkdocs build
site/
以下に生成される -
GitHub Pagesで公開する (
gh-deploy
branchにPush)-
GitHub Pagesの設定: 以下のように
gh-pages
ブランチを指定する -
GitHub Actions作成 (
main
branchにPushされたらDocsをビルドしてDeployする).github/workflows/publish.ymlname: publish on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: python-version: 3.9 - run: pip install mkdocs-material - run: mkdocs gh-deploy --force
-
GitHub Actionsを含めて、RepoへPush
-
https://nakamasato.github.io/mkdocs-material-sample/公開された! (自分の場合は、カスタムDomainを使っているので nakamasato.comとなった)
-
-
色などを変更できる
site_name: mkdocs sample theme: name: material palette: primary: cyan