Github Pages Reference
Github Pages Reference
By: supersimple.dev
Video Tutorial: https://youtu.be/p1QU3kLFPdg
GitHub Pages
Lets us put websites created with HTML, CSS, and JavaScript code on the Internet
Overall Process
1. Write your HTML, CSS, and JavaScript code on your computer (as normal)
2. Upload your code to a GitHub repository
3. Turn on GitHub Pages from the repository's settings
That's it!
Step By Step
1. Write the code for your website as normal (make sure your website works when you open the
HTML file in your browser)
2. In your browser, go to "github.com" and sign in
4. If you already have a repository, open it. Otherwise, on the right side click "New"
4a. When creating a new repository:
● Give it a name (any name is fine)
● Make sure it is "Public" (private repositories need to pay a fee to use GitHub Pages)
● Everything else can be left as default
6. Drag and drop the code you want to upload and click "Commit Changes" at the bottom.
❌ Don't drag the folder containing all your code into GitHub
✅ First open the folder, then select all your code and drag and drop into GitHub
10. To visit your GitHub Pages website, enter this URL at the top of your browser:
[your_github_username].github.io/[repository_name]/[file_name].html
If you don't provide an HTML file, GitHub Pages will look for a file called "index.html":
[your_github_username].github.io/[repository_name]
2. We'll link our domain name to GitHub Pages' IP address. Here's the diagram for reference
IP Address
● Is like a phone number (but for the Internet)
● Any device that connects to the Internet is given an IP address. At home, you connect to the
Internet through a router. In this case, only the router will get an IP address that is public
● A device can communicate with another device across the Internet using an IP address
IPv4 example: 185.199.108.153
IPv6 example: 2606:50c0:8000::153
4. Log into your domain registrar > open the "Settings" for your domain.
If you're not using Namecheap, see https://supersimple.dev/infrastructure/dns-records
In Namecheap:
● Go to your Dashboard > click "Domain List" on the left
● Find your domain > click "Manage" on the right > click "Advanced DNS"
● Look for this table (that lets us create DNS records):
Create a DNS A Record for each IP address from step 3. Here's the end result:
6. Create a CNAME Record = links a domain name to another domain name.
Set up the subdomain "www" (www.mywebsite.com). This is recommended by GitHub Pages.
Summary
A Record = mywebsite.com -> ip address
CNAME Record = subdomain.mywebsite.com -> domain name
Note
A CNAME Record can only be used when there is a subdomain. Some registrars offer an ALIAS
Record which can link the base domain name ("mywebsite.com") to another domain.
Set up Domain Name in GitHub Pages
1. Go to the GitHub repository for your website
3. In the "Custom domain" section, enter your domain name. Click Save
4. Wait for GitHub's process to finish. Then check the box to activate HTTPS
HTTPS encrypts all data flowing between your browser and your website.