Publishing a Website with GitHub Pages and Porkbun
Hosting a static website on GitHub Pages with a custom domain registered on Porkbun is one of the most efficient, secure, and cost-effective ways to publish a project online.
The infrastructure requires no dedicated servers or databases: HTML, CSS, and static assets are served directly from GitHub's global CDN with free automated SSL certificates.
Below is the complete step-by-step setup for repository configuration, DNS records, and automated deployment.
1. Repository Setup (CNAME File)
For GitHub Pages to know which domain should serve your repository, include a file named CNAME at the root of the publication output (for example, on the gh-pages branch or inside the directory generated by your static site generator).
The file content should only be your domain name, without protocols (https://) or trailing slashes:
renaldofreire.dev
If your project uses a static site generator (such as Frozen-Flask, Hugo, Zola, or Jekyll), ensure that your build step creates or copies this file into the final output directory.
2. DNS Configuration on Porkbun
In the Porkbun control panel, navigate to Domain Management, find your domain, and click on DNS Records.
Remove the default domain parking records and add the following entries:
A Records (Apex Domain @)
Create 4 A records pointing the host @ (or blank) to GitHub Pages' CDN IP addresses:
| Type | Host | Answer / Value | TTL |
|---|---|---|---|
| A | @ |
185.199.108.153 |
600 |
| A | @ |
185.199.109.153 |
600 |
| A | @ |
185.199.110.153 |
600 |
| A | @ |
185.199.111.153 |
600 |
(Optional: you can also configure the corresponding IPv6 AAAA records: 2606:50c0:8000::153, 2606:50c0:8001::153, 2606:50c0:8002::153, and 2606:50c0:8003::153).
CNAME Record (www Subdomain)
To ensure traffic from www.yourdomain.com resolves correctly, create a CNAME record:
| Type | Host | Answer / Value | TTL |
|---|---|---|---|
| CNAME | www |
<your-username>.github.io |
600 |
Replace <your-username> with your GitHub username.
3. Continuous Deployment with GitHub Actions
Instead of manually building and uploading files, configure a GitHub Actions workflow in .github/workflows/deploy.yml.
On every git push to the main branch, the runner prepares the environment, builds the static pages, and publishes the output to the gh-pages branch:
name: Build & Deploy
on:
push:
branches: [main]
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- name: Install dependencies
run: pip install -r requirements.txt
- name: Build static site
run: python freeze.py
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
publish_branch: gh-pages
4. Custom Domain and HTTPS Verification on GitHub
Once the initial deploy to the gh-pages branch succeeds:
- In the GitHub repository, navigate to Settings > Pages.
- Under Build and deployment, select:
- Source:
Deploy from a branch - Branch:
gh-pages// (root) - Under Custom domain, enter your domain (e.g.
renaldofreire.dev) and click Save. - GitHub will verify the DNS records configured on Porkbun. Once verified, check the Enforce HTTPS box. GitHub automatically issues and manages a free Let's Encrypt SSL certificate.
5. Verification via Terminal
To verify DNS propagation from the command line before testing in your browser:
dig +noall +answer renaldofreire.dev A
The output should list the 4 configured IP addresses:
renaldofreire.dev. 600 IN A 185.199.108.153
renaldofreire.dev. 600 IN A 185.199.109.153
renaldofreire.dev. 600 IN A 185.199.110.153
renaldofreire.dev. 600 IN A 185.199.111.153
With this setup in place, publishing updates is as simple as adding or editing markdown files and pushing to Git. The rest of the workflow is fully automated with zero hosting costs.