コンテンツにスキップ

MkDocs

MkDocs は、チームが製品、内部知識ベース、APIを文書化できる現代的なドキュメンテーションプラットフォームです。

MkDocsのインストール

MkDocsを使用するには、システムに最新のPythonバージョンとPythonパッケージマネージャーであるpipをインストールする必要があります。pipをインストールするには、MkDocsインストールガイドを参照してください。pipがインストールされたら、次のコマンドを実行します:

Terminal window
pip install mkdocs

MkDocsプロジェクトの作成

mkdocs newコマンドを使用して新しいアプリケーションを作成します:

Terminal window
mkdocs new <PROJECT_NAME>

次に、プロジェクトにcdし、MkDocsとその依存関係をrequirements.txtファイルに保存します:

Terminal window
pip freeze > requirements.txt

Before you continue

All of the framework guides assume you already have a fundamental understanding of Git. If you are new to Git, refer to this summarized Git handbook on how to set up Git on your local machine.

If you clone with SSH, you must generate SSH keys on each computer you use to push or pull from GitHub.

Refer to the GitHub documentation and Git documentation for more information.

Create a GitHub repository

Create a new GitHub repository by visiting repo.new. After creating a new repository, go to your newly created project directory to prepare and push your local application to GitHub by running the following commands in your terminal:

Terminal window
git init
git remote add origin https://github.com/<your-gh-username>/<repository-name>
git add .
git commit -m "Initial commit"
git branch -M main
git push -u origin main

GitHubリポジトリを正常に作成し、そのリポジトリにMkDocsプロジェクトをプッシュしました。

Cloudflare Pagesでのデプロイ

サイトをPagesにデプロイするには:

  1. Cloudflareダッシュボードにログインし、アカウントを選択します。
  2. アカウントホームで、Workers & Pages > アプリケーションの作成 > Pages > Gitに接続を選択します。
  3. 作成した新しいGitHubリポジトリを選択し、ビルドとデプロイの設定セクションで、MkDocsフレームワークプリセットとして選択します。選択により、次の情報が提供されます:
Configuration option Value
Production branch main
Build command mkdocs build
Build directory site
  1. 環境変数(詳細) > 変数を追加に進み、PYTHON_VERSIONという変数を値3.7で追加します。

サイトをデプロイした後、*.pages.devでプロジェクトのユニークなサブドメインを受け取ります。

MkDocsサイトに新しいコードをコミットするたびに、Cloudflare Pagesは自動的にプロジェクトを再ビルドしてデプロイします。また、新しいプルリクエストでプレビューのデプロイにアクセスでき、変更が本番環境にデプロイされる前にサイトの見た目をプレビューできます。

Cloudflare Pagesに最初のサイトをデプロイするための完全なガイドについては、はじめにガイドを参照してください。

Learn more

By completing this guide, you have successfully deployed your MkDocs site to Cloudflare Pages. To get started with other frameworks, refer to the list of Framework guides.