静的HTML
Cloudflareは、任意の静的HTMLウェブサイトをCloudflare Pagesにデプロイすることをサポートしています。フレームワークや静的サイトジェネレーターを使用せずにウェブサイトを管理している場合、または使用しているフレームワークがフレームワークガイドにリストされていない場合でも、このガイドを使用してデプロイできます。
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 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:
git initgit remote add origin https://github.com/<your-gh-username>/<repository-name>git add .git commit -m "Initial commit"git branch -M maingit push -u origin mainサイトをPagesにデプロイするには:
- Cloudflareダッシュボード ↗にログインし、アカウントを選択します。
- アカウントホームで、Workers & Pages > アプリケーションを作成 > Pages > Gitに接続を選択します。
- 作成した新しいGitHubリポジトリを選択し、ビルドとデプロイの設定セクションで、次の情報を提供します:
| 設定オプション | 値 |
|---|---|
| プロダクションブランチ | main |
| ビルドコマンド(オプション) | exit 0 |
| ビルド出力ディレクトリ | <YOUR_BUILD_DIR> |
多くのフレームワークガイドとは異なり、サイトのビルドコマンドとビルド出力ディレクトリは完全にカスタムになります。プリセットを使用しておらず、サイトをビルドする必要がない場合は、ビルドコマンドとしてexit 0を使用してください。Cloudflareは、Pages Functionsなどの機能にアクセスするために、ビルドコマンドとしてexit 0を使用することを推奨しています。ビルド出力ディレクトリは、アプリケーションのコンテンツが存在する場所です。
サイトの設定が完了したら、最初のデプロイを開始できます。提供された場合はカスタムビルドコマンドが実行され、Pagesが静的サイトをデプロイします。
サイトをデプロイした後、*.pages.devのプロジェクト用のユニークなサブドメインが割り当てられます。Cloudflare Pagesは自動的にプロジェクトを再構築し、デプロイします。また、新しいプルリクエストに対してプレビューのデプロイにアクセスできるようになり、変更が本番環境にデプロイされる前にサイトにどのように表示されるかをプレビューできます。
*.pages.devで404エラーが発生していますか?
*.pages.devドメインを訪問した際に404エラーが発生する場合は、ウェブサイトにindex.htmlのトップレベルファイルがあることを確認してください。このindex.htmlは、ページが指定されていない状態でPagesがエイペックスで提供するものです。
By completing this guide, you have successfully deployed your site to Cloudflare Pages. To get started with other frameworks, refer to the list of Framework guides.