How To Create A GitHub Page

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:

  1. Create a Repository (Click the plus button + and then New Repository).
  2. 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).
  3. Make it public or private, it doesn’t matter.
  4. Click add a README.md file.
  5. Finally click create Repository.

How Do You Make It A Page?

To make your Repository into a Page you must:

  1. Click on the Settings button (if you cannot see the button, first click the dropdown button).
  2. Go to the Code and Automation tab and click on Pages.
  3. Go to Build and Deployment, in Branch and select a publishing source such as Main.
  4. Click Save when you’re done.
  5. Go back to the Code tab and go to the About section.
  6. Click the gear icon and under Website click Use your GitHub Pages website.

How Do You Add A Custom URL?

To add a custom domain to your Repository you must:

  1. Go to the Settings tab.
  2. Go to the Code and Automation section and click Pages.
  3. Under Custom Domain type in your domain name.
  4. Click Save. (If you are publishing your site from a branch, this will create a commit that adds a CNAME file to the root of your source branch. If you are publishing your site with a custom GitHub Actions workflow , no CNAME file is created.)

Configuring a Subdomain

  1. 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 subdomain www.example.com for your user site, create a CNAME record that points www.example.com to <user>.github.io . If you want to use the subdomain another.example.com for your organization site, create a CNAME record that points another.example.com to <organization>.github.io . The CNAME record should always point to <user>.github.io or <organization>.github.io , excluding the repository name.
  2. Go to the terminal, and to confirm that your DNS record configured correctly, use the dig command, replacing WWW.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

  1. Go to your DNS provider where you are hosting your domain and create either an ALIAS , ANAME , or A record. You can also create AAAA records for IPv6 support. If you’re implementing IPv6 support, we highly recommend using an A record in addition to your AAAA 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 or ANAME 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
  1. Open your terminal, and to confirm that your DNS record configured correctly, use the dig command, replacing EXAMPLE.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!

9 Likes

Thanks, this actually worked!

3 Likes