Hosting a static site with GitHub Pages
GitHub Pages gives every repository a free, secure home for a static website. If you have a GitHub account and a project ready to publish, you can have a live site in a few minutes—no separate hosting bill, no infrastructure setup.
The workflow is straightforward whether you start from an existing repository or create a new one. A sample repository with a Next.js static site is available if you want to follow along; fork it and you're ready to deploy.
Two ways to publish
GitHub Pages offers two deployment paths: Deploy from a branch and GitHub Actions. Both live under the repository's Settings tab, in the Pages section under "Code and automation."
Deploying from a branch
This is the simplest option. From the Pages settings:
- Under "Build and deployment," select Deploy from a branch.
- Choose
mainas the branch to deploy from. - Click Save.
That's it—the site is now publicly available from the main branch.
Deploying with GitHub Actions
For more control over the build and deploy process—especially with frameworks like Next.js—use a workflow instead:
- In Pages settings, switch "Source" to GitHub Actions. Suggested workflows will appear.
- Select browse all workflows, then search for "next.js."
- Click Configure on the Next.js workflow box.
- Review the file's permissions and build steps; no changes are needed for the sample repo.
- Click Commit changes at the top-right, add a commit message, and commit to
main. - Open the Actions tab and wait for the run to finish.
- Open the action named Add GitHub Actions workflow for Next.js deployment. If no website link appears in the "deploy" box, there's a second action with the same name—open that one instead.
- Click the link in the "deploy" box to view your hosted site.
Note that a successful deployment from a private repository still results in a public website. To see who deployed last, return to Settings → Pages.
Using a custom domain
Pages sites default to USERNAME.github.io/REPOSITORY-NAME. To use your own domain, you first need two prerequisites: DNS records configured with your domain provider, and the domain verified at your org or profile level. GitHub's documentation covers both managing and verifying custom domains.
Once those are set:
- Go to Settings → Pages.
- Enter the domain under "Custom domain" and click Save. GitHub will check the DNS configuration and confirm it with a green checkmark.
- After verification, tick Enforce HTTPS to enable a free SSL certificate and the browser padlock.
Custom domains give your project a professional-looking URL, and the deployment itself stays free regardless of which hosting path you pick.
For further reading, the GitHub Pages documentation covers site creation, and the custom domains guide explains DNS configuration and apex domain behavior in more depth.



