コンテンツにスキップ

Gridsome

Gridsome は、デフォルトで高速な静的生成されたウェブサイトやアプリケーションを構築するための Vue.js ベースの Jamstack フレームワークです。このガイドでは、新しい Gridsome プロジェクトを作成し、Cloudflare Pages を使用してデプロイします。新しい Gridsome プロジェクトを作成するためのコマンドラインツールである @gridsome/cli を使用します。

Gridsome のインストール

ターミナルで以下のコマンドを実行して @gridsome/cli をインストールします。

Terminal window
npm install --global @gridsome/cli

新しいプロジェクトのセットアップ

Gridsome をインストールしたら、gridsome create を実行して新しいプロジェクトをセットアップします。create コマンドは、作成されるプロジェクトのディレクトリを定義する名前と、オプションのスターターキット名を受け入れます。より多くのスターターについては、Gridsome スターターセクションを確認できます。

Terminal window
npx gridsome create my-gridsome-website

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

Cloudflare Pages でのデプロイ

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

  1. Cloudflare ダッシュボード にログインし、アカウントを選択します。
  2. アカウントホームで、Workers & Pages > アプリケーションを作成 > Pages > Git に接続を選択します。
  3. 作成した新しい GitHub リポジトリを選択し、ビルドとデプロイの設定セクションで、以下の情報が提供されます:
Configuration option Value
Production branch main
Build command npx gridsome build
Build directory dist

サイトの設定が完了したら、最初のデプロイを開始できます。Cloudflare Pages が vuepress、プロジェクトの依存関係をインストールし、サイトをビルドしてからデプロイするのを見ることができるはずです。

サイトをデプロイした後、*.pages.dev のプロジェクト用のユニークなサブドメインが提供されます。Gridsome プロジェクトに新しいコードをコミットするたびに、Cloudflare Pages は自動的にプロジェクトを再ビルドしてデプロイします。また、新しいプルリクエストで プレビュー デプロイメント にアクセスできるため、変更を本番環境にデプロイする前にサイトの変更がどのように見えるかをプレビューできます。

Learn more

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