How To Create A GitHub Page
What Is A GitHub Page?
- A GitHub Page is a static website
- It automatically uses this format for URLs
<username>.github.io
or<organization name>.github.io
- It has the ability for custom URLs
How Do You Setup A Page?
To setup your Page you must:
- Create a Repository (Click the plus button
+
and thenNew Repository
). - Name the Repository your username or organization name with
github.io
on the end (make sure it’s the same as the account you are using). - Make it public or private, it doesn’t matter.
- Click add a
README.md
file. - Finally click create Repository.
How Do You Make It A Page?
To make your Repository into a Page you must:
- Click on the
Settings
button (if you cannot see the button, first click the…
dropdown button). - Go to the
Code and Automation
tab and click onPages
. - Go to
Build and Deployment
, inBranch
and select a publishing source such asMain
. - Click
Save
when you’re done. - Go back to the
Code
tab and go to theAbout
section. - Click the gear icon and under
Website
clickUse your GitHub Pages website
.
How Do You Add A Custom URL?
To add a custom domain to your Repository you must:
- Go to the
Settings
tab. - Go to the
Code and Automation
section and clickPages
. - Under
Custom Domain
type in your domain name. - Click
Save
. (If you are publishing your site from a branch, this will create a commit that adds aCNAME
file to the root of your source branch. If you are publishing your site with a custom GitHub Actions workflow , noCNAME
file is created.)
Configuring a Subdomain
- Go to the DNS provider you have chosen to host your domain on and create a
CNAME
record that points your subdomain to the default domain for your site. For example, if you want to use the subdomainwww.example.com
for your user site, create aCNAME
record that pointswww.example.com
to<user>.github.io
. If you want to use the subdomainanother.example.com
for your organization site, create aCNAME
record that pointsanother.example.com
to<organization>.github.io
. TheCNAME
record should always point to<user>.github.io
or<organization>.github.io
, excluding the repository name. - Go to the terminal, and to confirm that your DNS record configured correctly, use the
dig
command, replacingWWW.EXAMPLE.COM
with your domain name. (If you use a static site generator to build your site locally and push the generated files to GitHub, pull the commit that added the CNAME file to your local repository. Optionally, to enforce HTTPS encryption for your site, select Enforce HTTPS. It can take up to 24 hours before this option is available)
Configuring an Apex Domain
- Go to your DNS provider where you are hosting your domain and create either an
ALIAS
,ANAME
, orA
record. You can also createAAAA
records for IPv6 support. If you’re implementing IPv6 support, we highly recommend using anA
record in addition to yourAAAA
record, due to slow adoption of IPv6 globally. For more information about how to create the correct record, see your DNS provider’s documentation.
-
To create an
ALIAS
orANAME
record, point your apex domain to the default domain for your site. -
To create
A
records, point your apex domain to the IP addresses for GitHub Pages.
185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
- To create
AAAA
records, point your apex domain to the IP addresses for GitHub Pages.
2606:50c0:8000::153
2606:50c0:8001::153
2606:50c0:8002::153
2606:50c0:8003::153
- Open your terminal, and to confirm that your DNS record configured correctly, use the
dig
command, replacingEXAMPLE.COM
with your apex domain. Confirm that the results match the IP addresses for GitHub Pages above.
- For
A
records:
$ dig EXAMPLE.COM +noall +answer -t A
> EXAMPLE.COM 3600 IN A 185.199.108.153
> EXAMPLE.COM 3600 IN A 185.199.109.153
> EXAMPLE.COM 3600 IN A 185.199.110.153
> EXAMPLE.COM 3600 IN A 185.199.111.153
- For
AAAA
records:
$ dig EXAMPLE.COM +noall +answer -t AAAA
> EXAMPLE.COM 3600 IN AAAA 2606:50c0:8000::153
> EXAMPLE.COM 3600 IN AAAA 2606:50c0:8001::153
> EXAMPLE.COM 3600 IN AAAA 2606:50c0:8002::153
> EXAMPLE.COM 3600 IN AAAA 2606:50c0:8003::153
Remember to also check your A
record.
(If you use a static site generator to build your site locally and push the generated files to GitHub, pull the commit that added the CNAME file to your local repository. Optionally, to enforce HTTPS encryption for your site, select Enforce HTTPS. It can take up to 24 hours before this option is available)
End
Hope everyone found this helpful and will use it in the future. Hope you have a great day!