GitHub初心者向け:GitHub Pagesの始め方
GitHub公式ブログは、GitHub Pagesを使用して静的ウェブサイトを無料で公開するための2つの方法(ブランチからのデプロイとGitHub Actionsワークフロー)を初心者向けにステップバイステップで解説するチュートリアル記事を公開した。
キーポイント
GitHub Pagesの基本概念
GitHub Pagesは、GitHubリポジトリ内の静的ウェブサイトを無料で公開できるホスティングサービスであり、GitHubアカウント、デプロイするプロジェクト、数分の時間だけで利用可能である。
ブランチからのデプロイ方法
リポジトリのSettings > Pagesで「Build and deployment」から「Deploy from a branch」を選択し、デプロイ元のブランチ(例:main)を指定して保存することで、ウェブサイトを公開できる。
GitHub Actionsを使用したデプロイ方法
同じ設定画面で「Source」を「GitHub Actions」に変更し、表示されるワークフロー(例:Next.js用)を選択・コミットすると、Actionsタブで実行を監視し、完了後にサイトが公開される。
チュートリアルの構成と対象
この記事は「GitHub for Beginners」シリーズの一部であり、サンプルリポジトリのフォークを使用した実践的な手順を提供し、動画版もYouTubeで視聴可能である。
影響分析・編集コメントを表示
影響分析
この記事はGitHubの既存機能であるPagesの使い方を解説するチュートリアルであり、新規性や技術的革新性は低いが、開発者コミュニティにおける知識普及とオンボーディングには貢献する。AI業界との直接的な関連性は薄く、一般的な開発者向け教育コンテンツとしての位置付けである。
編集コメント
AI/テクノロジーニュースの専門アナリスト視点では、これは既存サービスの使い方解説であり、技術的進展や業界動向を報じるニュースではない。開発者教育コンテンツとして実用性は高いが、分析対象としての重要度は限定的。
タイトル: GitHub for Beginners: GitHub Pages の始め方
GitHub for Beginners へようこそ。これまでに、GitHub Issues と Projects、GitHub Actions について説明し、セキュリティについても少し触れました。今回は、GitHub Pages についてお話しします。
GitHub では、どのプロジェクトでもすぐに利用できる無料で安全なホスティングサービスにアクセスできることをご存知ですか?それが GitHub Pages です。静的ウェブサイトを含む任意の GitHub リポジトリを、無料で公開されたライブサイトに変える方法です。必要なのは次の3つだけです:
GitHub アカウント
デプロイするプロジェクト
GitHub Pages へのデプロイに要する数分間
このブログの手順に従えば、あなたのプロジェクトはライブになり、検索可能になり、共有する準備が整います。さあ、始めましょう!
いつものように、動画で視聴したい場合や参照したい場合は、GitHub for Beginners の全エピソードを YouTube でご覧いただけます。
GitHub Pages へのデプロイ
始めるには、サンプルリポジトリに移動し、ご自身で手順を試すためにリポジトリのフォークを作成してください。このリポジトリには Next.js で生成された静的ウェブサイトが含まれています。すでに GitHub にプッシュされているため、デプロイの準備が整っています。
プロジェクトを GitHub Pages にデプロイするには2つの異なる方法があります:ブランチからのデプロイ、または GitHub Actions の使用です。まず、ブランチからのデプロイを見てみましょう。
- リポジトリの上部にある「Settings」タブを選択します。
- 左側のメニューから「Pages」を選択します。これは設定の「Code and automation」セクションにあります。
- 「Build and deployment」の下にあるドロップダウンメニューを使用し、「Deploy from a branch」を選択します。
- 「Branch」の下で、ドロップダウンメニューを使用してデプロイ元のブランチとして「main」を選択します。
- 「Save」をクリックします。
これにより、main ブランチからウェブサイトが公開され、一般に利用可能になります。
GitHub Actions でのデプロイ
次に、GitHub Actions ワークフローを使用した公開方法を見てみましょう。すでに適切な設定ページにいるので、ここから続けます。
- 「Source」の下で、ドロップダウンメニューを使用して「GitHub Actions」を選択します。選択すると、GitHub はいくつかの推奨ワークフローを提供します。
- 「browse all workflows」を選択して、利用可能なすべてのワークフローを表示します。これにより、さまざまな言語向けのあらゆるワークフローが表示された新しいページに移動します。
- 検索ボックスに「next.js」と入力して、可能なワークフローをフィルタリングします。
- 「Next.js」ワークフローボックスの「Configure」ボタンをクリックします。これにより、ワークフローファイルに移動します。
- ファイルを確認し、設定されている権限とビルドおよびデプロイの指示を確認します。
- ファイルに変更は必要ないため、ウィンドウの右上にある緑色の「Commit changes」ボタンを選択します。
- コミットメッセージを入力するか、Copilot に作成させます。
- main ブランチにコミットするオプションが選択されていることを確認し、ウィンドウ下部の「Commit changes」をクリックします。
- 変更がコミットされたら、「Actions」タブを選択し、アクションが完了するのを待ちます。
- 「Add GitHub Actions workflow for Next.js deployment」アクションの名前を選択します。同じ名前のアクションが2つあることに注意してください。アクションが正常に完了し、「deploy」ボックスにウェブサイトリンクが表示されない場合は、戻って同じ名前のもう一方のアクションを選択してください。
- 「deploy」ボックス内のリンクを選択して、GitHub Pages でホストされているあなたのウェブサイトを表示します。
おめでとうございます!GitHub Pages へのウェブサイトのデプロイに成功しました。リポジトリがプライベートであっても、公開されたウェブサイトはパブリックになることに注意してください。誰が最も最近にあなたのウェブサイトをデプロイしたかを確認したい場合は、Settings -> Pages に戻ることで確認できます。
カスタムドメインの追加
デフォルトでは、GitHub Pages 上のすべてのウェブサイトは次の URL になります:USERNAME.github.io/REPOSITORY-NAME。
ただし、必要に応じてカスタムドメインを使用するように更新できます。これを行うには、まずドメインプロバイダーで DNS レコードを設定する必要があります。カスタムドメインの管理に関するドキュメントを参照して、詳細を確認できます。また、組織またはプロファイルレベルでドメインを検証する必要があります。
DNS レコードを設定し、ドメインを検証したら、次の手順に従ってカスタムドメインを設定できます:
- Settings -> Pages に移動します。
- 「Custom domain」の下で、提供されたボックスにドメイン名を入力します。
- カスタムドメインの横にある「Save」を選択します。ドメイン名を更新すると、GitHub は自動的にドメインの DNS 設定をチェックします。すべてが問題なければ、緑色のチェックマークが表示されます。
- ドメインが検証されたら、「Enforce HTTPS」チェックボックスを選択します。これにより、無料の SSL 証明書でサイトが保護され、訪問者がブラウザで安全な南京錠を確認できるようになります。
次のステップ
これで、デプロイするプロジェクトを選択し、ブランチから、または GitHub Actions を使用してリポジトリのウェブサイトを作成する方法がわかりました。それだけでなく、ドメインをカスタマイズすることもでき、すべて無料で利用できます!プロジェクト自体がプライベートであっても、これを使用してプロジェクトを宣伝したり、取り組んでいることを共有したり、ポートフォリオを充実させたりしてください。
GitHub Pages についてさらに学びたい場合は、次のリソースが参考になります:
- GitHub Pages メインのドキュメントサイト
- GitHub Pages サイトの作成
- カスタムドメインについて
Happy coding!
この投稿「GitHub for Beginners: GitHub Pages の始め方」は、The GitHub Blog に最初に掲載されました。
原文を表示
Welcome back to GitHub for Beginners. So far, we’ve discussed GitHub Issues and Projects, GitHub Actions, and covered a bit about security. This time, we’re going to talk about GitHub Pages.
Did you know that you have access to a free and secure hosting service on GitHub, readily available for any project? That’s what GitHub Pages is—a way to turn any GitHub repository with a static website into a live site for free. You just need three things:
A GitHub account
A project to deploy
A few minutes to deploy to GitHub Pages
Follow the steps in this blog and your project will be live, searchable, and ready to share. Let’s get started!
As always, if you prefer to watch the video or want to reference it, we have all of our GitHub for Beginners episodes available on YouTube.
Deploying to GitHub Pages
To get started, navigate to the sample repository, and create a fork of the repository that you can use for your own walkthrough. This repository has a static website generated with Next.js. Since it’s already been pushed up to GitHub, it’s ready to deploy.
There are two different ways that you can deploy your project to GitHub Pages: deploying from a branch or using GitHub Actions. First, let’s look at deploying from a branch.
Select the Settings tab at the top of the repository.
Select Pages from the left-hand menu. It’s located in the “Code and automation” section of the settings.
Use the combo box under “Build and deployment” and select Deploy from a branch.
Under “Branch,” use the combo box to select main as the branch to deploy from.
Click Save.
This publishes the website from the main branch and makes it publicly available.
Deploying with GitHub Actions
Now let’s look at publishing using the GitHub Actions workflow. Since we’re already on the appropriate Settings page, we’ll pick up from here.
Under “Source,” use the combo box and select GitHub Actions. Once you do, GitHub will provide some suggested workflows.
Select browse all workflows to see all the possible workflows available.This will send you to a new page with all sorts of workflows for different languages.
Enter “next.js” into the search box to filter the possible workflows.
Click the Configure button in the “Next.js” workflow box. This takes you to the workflow file.
Review the file and verify the permissions that are set as well as the build and deploy instructions.
Since the file does not require any changes, select the green Commit changes button at the top-right of the window.
Provide a commit message or have Copilot create one for you.
Make sure the option to commit to the main branch is selected, then click Commit changes at the bottom of the window.
Once the changes have been committed, select the Actions tab and wait for the actions to complete.
Select the name of the Add GitHub Actions workflow for Next.js deployment action. Note that there will be two actions with the same name. If the action has successfully completed and does not show a website link in the “deploy” box, you want to go back and select the other action with an identical name.
Select the link in the “deploy” box to see your website hosted on GitHub Pages.
Congratulations! You have successfully deployed a website to GitHub Pages. Keep in mind that even if your repository is private, the published website will still be public. If you ever want to see who most recently deployed your website, you can do so by navigating back to Settings -> Pages.
Adding a custom domain
By default, all websites on GitHub Pages will have the following URL: USERNAME.github.io/REPOSITORY-NAME.
However, you can update this to use your custom domain if you want. To do this, you’ll first need to configure DNS records with your domain provider. You can read more about how to do this by checking out our docs on managing a custom domain. You’ll also need to verify your domain at the org or profile level.
Once you’ve configured the DNS records and verified the domain, you can set the custom domain by following these steps:
Navigate to Settings -> Pages.
Under “Custom domain,” enter your domain name into the box provided.
Select Save next to your custom domain. After you update the domain name, GitHub automatically checks your domain’s DNS configuration. If everything seems good, you’ll see a green checkmark.
Once the domain has been verified, select the Enforce HTTPS checkbox. This secures your site with a free SSL certificate and makes sure visitors see that secure padlock in their browser.
What’s next?
Now you know how to select a project to deploy and create a website for the repository either from a branch or by using GitHub Actions. Not only that, but you can customize the domain, and it’s all available for free! Use this to promote your projects, share what you’re working on, or expand your portfolio, even if the projects themselves are private.
If you want to learn more about GitHub Pages, here are some good places to get started:
The GitHub Pages main doc site
Creating a GitHub Pages site
About custom domains
Happy coding!
The post GitHub for Beginners: Getting started with GitHub Pages appeared first on The GitHub Blog.
関連記事
VercelがTurboビルドマシンの価格を16%値下げ
VercelはTurboビルドマシンの価格を16%値下げし、全ビルドをCPU1分あたり0.0035ドルに設定した。30CPUのTurboマシンは1分あたり0.105ドルとなる。この変更は4月15日から適用される。
GitHub のエージェント計画に関する Kyle Daigle とのインタビュー
Microsoft の Satya Nadella 氏と共同で AI Engineer World's Fair に参加し、Kyle Daigle が GitHub のエージェント戦略や Copilot の稼働率について質問に答えた。
リポジトリ内の全プロジェクトの Git 設定を編集可能に
Vercel は、モノレポで多数のプロジェクトを展開するユーザー向けに、各プロジェクトの Git 設定(コミットステータスやリポジトリディスパッチイベントなど)を一括で管理・適用できる機能を追加した。これにより、個別の設定画面へのアクセスが不要となり、効率的な運用が可能になった。