2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GitHub Pages デプロイ 2 大ルートをサクッと解説 🛣️✨

2
Last updated at Posted at 2025-06-23

GitHub Pages で 静的サイトを爆速公開 するなら、この 2 ルートを押さえれば OK!
どちらも GitHub 公式サポートなので、安心してガンガン使える 💪🎉

1. ブランチ方式 🚢

手順 ポイント
gh-pages などの公開用ブランチを作成 ビルド済みファイルをコミットして配置する
git push でブランチを更新 GitHub Pages がブランチ内容をそのまま配信

📝 公式ドキュメント: Configuring a publishing source — 公開ブランチの設定方法。

2. アーティファクト方式(GitHub Actions)🚀

手順 アクション / 役割
1️⃣ ビルド npm run build などで静的ファイルを生成
2️⃣ アップロード actions/upload-pages-artifact で生成物をアーティファクト化
3️⃣ デプロイ actions/deploy-pages でアーティファクトを GitHub Pages に公開

🔗 参考:

📜 サンプルワークフロー YAML(コピペで即デプロイ!)

name: Deploy to GitHub Pages
on:
  push:
    branches: ["main"]
  workflow_dispatch:

permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build static site
        run: |
          npm ci
          npm run build
      - name: Upload Pages artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: ./dist

  deploy:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

upload-pages-artifact でファイルをギュッと固め、deploy-pages でズドンと公開! 🚀

まとめ 🔮

方式 オススメ場面
ブランチ方式 ビルドが必要ないページを公開する場合
アーティファクト方式 MkDocs等ビルドが必要なページを公開する場合

参考リンク 🔗

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?