📝 Table of Contents
What is GitHub Pages?
GitHub Pages is a FREE website hosting service from GitHub. It turns your code files into live websites that anyone can visit on the internet.
Think of it like this:
- Google App Script: Your code runs on Google's servers
- GitHub Pages: Your HTML file becomes a live website on GitHub's servers
What You Can Do:
- Publish calculators, games, tools
- Share portfolio projects
- Host documentation
- Create landing pages
What You Cannot Do:
- Run server-side code (PHP, Python servers, etc.)
- Store user data permanently (no database)
- Upload files larger than 100MB
Setting Up Your GitHub Account
1 Create Your Account
- Go to
https://github.com - Click the "Sign up" button (top right)
- Enter your email address
- Create a password (use something secure!)
- Choose a username (this will be in your website URL)
- Complete the verification puzzle
- Click "Create account"
https://username.github.io
2 Verify Your Email
- Check your email inbox
- Find the email from GitHub
- Click the verification link
- You're ready to start!
Creating Your First Project (Repository)
A repository (or "repo") is like a project folder. Each website needs its own repository.
1 Create New Repository
- Log into GitHub
- Click the green "New" button (top left corner)
- Or click your profile picture → "Your repositories" → "New"
2 Fill Out Repository Details
- Repository name: Choose a name (e.g.,
my-calculator) - Description: Optional, but helpful (e.g., "Simple calculator app")
- Public/Private: Choose Public (required for free GitHub Pages)
- Check: "Add a README file"
- Click the green "Create repository" button
https://username.github.io/repository-name
Publishing Your HTML File
1 Add Your HTML File
- Inside your repository, click "Add file" button
- Select "Create new file"
- Name your file:
index.html - Copy and paste your entire HTML code into the editor
- Scroll to bottom
- Click green "Commit new file" button
index.html (all lowercase) for GitHub Pages to work automatically!
2 Enable GitHub Pages
- Click the "Settings" tab (top of your repository)
- Look at the left sidebar
- Scroll down and click "Pages"
- Under "Source" (or "Branch"), select "main" from the dropdown
- Click "Save"
- Wait 1-2 minutes
- Refresh the page
- You'll see a blue/green box with your website link!
https://yourusername.github.io/repository-name
3 Visit Your Live Website!
Click the link provided or type it into your browser. Your app is now live on the internet!
Understanding the .nojekyll File
What is Jekyll?
Jekyll is a tool GitHub uses automatically to process your files. It was designed for blogs and documentation sites.
The Problem:
Jekyll can "break" or hide some of your files, especially:
- Files or folders starting with underscore (_myfile.js)
- Certain JavaScript frameworks
- Files with special characters
The Solution: .nojekyll File
This tiny file tells GitHub: "Don't process my files, just publish them exactly as they are!"
1 When to Add .nojekyll
Add this file if:
- Your JavaScript/CSS works locally but breaks on GitHub Pages
- You're using files/folders with underscores
- You want to prevent any processing (safer choice)
2 How to Create .nojekyll
- In your repository, click "Add file"
- Click "Create new file"
- Type the filename:
.nojekyll(yes, it starts with a dot!) - Leave the file completely empty (no text needed!)
- Scroll down and click "Commit new file"
Updating Your Project (Copy-Paste Method)
This is the easiest way to update your website - just like you do in App Script!
1 Edit Your HTML File
- Go to your repository
- Click on
index.html - Click the pencil icon (top right, says "Edit this file")
- Select all the old code (long press and select all)
- Delete it
- Paste your new code
2 Save Your Changes
- Scroll to the bottom
- In "Commit changes" box, you can add a note (optional)
- Click green "Commit changes" button
3 Wait for Update
- Wait 1-2 minutes for GitHub to rebuild your site
- Check the "Actions" tab to see progress (optional)
- Visit your website and refresh
Common Challenges & Solutions
Challenge 1: "404 - Page Not Found"
Solutions:
- Make sure your file is named exactly
index.html(lowercase) - Wait 5 minutes after enabling Pages - it takes time!
- Check Settings → Pages - make sure it says "Your site is live at..."
- Make sure your repository is Public, not Private
Challenge 2: "My site shows old version"
Solutions:
- Wait 2-5 minutes for GitHub to rebuild
- Check "Actions" tab for green checkmark (means deployment finished)
- Try opening in incognito/private window
- Clear all browser cache and cookies
Challenge 3: "CSS/JavaScript not working"
Solutions:
- Make sure everything is in ONE file (index.html)
- Check for file path errors (no external file links)
- Add
.nojekyllfile to your repository - Open browser console to see error messages
- Make sure you're using
<style>tags for CSS and<script>tags for JavaScript
Challenge 4: "100% HTML warning"
What it means:
- 100% HTML = Your project is pure HTML (perfectly fine!)
- It's just a label showing code composition
- Single-file apps are usually 100% HTML
- You can completely ignore this
Challenge 5: "Images not showing"
Solutions:
- Use full URLs for images:
https://example.com/image.jpg - Or use Base64 encoded images directly in HTML
- Upload images to repository and use relative paths:
./image.jpg - Use image hosting services (Imgur, Cloudinary, etc.)
Challenge 6: "Can't find the Settings tab"
Solutions:
- Make sure you're in YOUR repository, not someone else's
- Settings tab is at the top, usually the last tab on the right
- You must be the repository owner to see Settings
Challenge 7: "My code has errors"
Solutions:
- Test your code locally first (open HTML file in browser)
- Use browser console to see error messages
- Check for missing closing tags:
</div>,</script>, etc. - Validate HTML at:
https://validator.w3.org/ - Check for typos in function names
Best Practices for Single-File Apps
1. File Organization
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Your App Name</title>
<!-- All your CSS here -->
<style>
/* Your styles */
</style>
</head>
<body>
<!-- Your HTML content here -->
<!-- All your JavaScript at the end -->
<script>
// Your code
</script>
</body>
</html>
2. Keep It Simple
- One file is easier to manage
- No need for separate CSS/JS files for small projects
- Easier to copy-paste and update
3. Test Before Publishing
- Save your HTML file on your phone
- Open it in a browser
- Make sure everything works
- Then upload to GitHub
4. Use Meaningful Names
- Repository:
tax-calculator(notproject1) - Main file: Always
index.html - Commit messages: "Fixed calculator bug" (not "update")
5. Comment Your Code
<!-- Calculator Display -->
<div id="display">0</div>
<script>
// Function to add two numbers
function add(a, b) {
return a + b;
}
</script>
6. Always Include Viewport Meta Tag
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7. Use External Libraries via CDN
Instead of downloading libraries, link to them:
<!-- For charts -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<!-- For styling -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
Practice Examples
Example 1: Simple Counter App
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Counter App</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: Arial;
text-align: center;
padding: 20px;
background: linear-gradient(135deg, #5A67D8, #4C51BF);
min-height: 100vh;
}
.container {
background: white;
padding: 30px;
border-radius: 15px;
max-width: 400px;
margin: 50px auto;
}
#count {
font-size: 60px;
color: #5A67D8;
margin: 20px 0;
}
button {
padding: 15px 25px;
font-size: 18px;
margin: 8px;
cursor: pointer;
border: none;
border-radius: 8px;
background: #5A67D8;
color: white;
width: 80px;
}
button:active { background: #4C51BF; transform: scale(0.95); }
</style>
</head>
<body>
<div class="container">
<h1>Counter App</h1>
<div id="count">0</div>
<button onclick="decrease()">-</button>
<button onclick="reset()">Reset</button>
<button onclick="increase()">+</button>
</div>
<script>
let count = 0;
function increase() { count++; updateDisplay(); }
function decrease() { count--; updateDisplay(); }
function reset() { count = 0; updateDisplay(); }
function updateDisplay() {
document.getElementById('count').innerText = count;
}
</script>
</body>
</html>
Example 2: Simple To-Do List
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>To-Do List</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: Arial;
background: #F7FAFC;
padding: 20px;
}
.container {
max-width: 500px;
margin: 20px auto;
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}
h1 { color: #5A67D8; margin-bottom: 15px; }
input {
width: 70%;
padding: 12px;
font-size: 16px;
border: 2px solid #E2E8F0;
border-radius: 5px;
}
button {
padding: 12px 20px;
font-size: 16px;
background: #5A67D8;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:active { background: #4C51BF; }
ul { list-style: none; margin-top: 15px; }
li {
padding: 12px;
background: #F7FAFC;
margin: 8px 0;
border-radius: 5px;
cursor: pointer;
}
li:active { background: #E2E8F0; }
.completed {
text-decoration: line-through;
opacity: 0.6;
}
</style>
</head>
<body>
<div class="container">
<h1>My To-Do List</h1>
<input type="text" id="taskInput" placeholder="Enter a task...">
<button onclick="addTask()">Add</button>
<ul id="taskList"></ul>
</div>
<script>
function addTask() {
const input = document.getElementById('taskInput');
const task = input.value.trim();
if (task === '') { alert('Please enter a task!'); return; }
const li = document.createElement('li');
li.textContent = task;
li.onclick = function() { this.classList.toggle('completed'); };
document.getElementById('taskList').appendChild(li);
input.value = '';
}
document.getElementById('taskInput').addEventListener('keypress', function(e) {
if (e.key === 'Enter') addTask();
});
</script>
</body>
</html>
Quick Reference Checklist
Publishing a New Project:
- Create GitHub account (if needed)
- Click "New" repository button
- Name your repository (lowercase, hyphens only)
- Make it Public
- Check "Add README file"
- Create repository
- Add file → Create new file
- Name it
index.html - Paste your HTML code
- Commit new file
- Go to Settings → Pages
- Select "main" branch
- Click Save
- Wait 2-5 minutes
- Visit your website URL!
Updating Your Project:
- Go to your repository
- Click on
index.html - Click pencil icon
- Select all
- Paste new code
- Commit changes
- Wait 1-2 minutes
- Refresh your browser
Troubleshooting Checklist:
- File named
index.htmlexactly? - Repository is Public?
- Pages enabled in Settings?
- Waited 5 minutes?
- Refreshed browser?
- Checked Actions tab for errors?
- Tried incognito mode?
- Added
.nojekyllif needed?
Key URLs to Remember:
- GitHub:
https://github.com - Your Profile:
https://github.com/yourusername - Your Website:
https://yourusername.github.io/repo-name
Final Tips for Success
Learning Path:
- Create account and first repository (today!)
- Publish one of the example projects above
- Make a simple project of your own
- Practice updating it several times
- Try more complex projects
- Share your projects with others!
Resources:
- GitHub Pages Docs:
https://pages.github.com - GitHub Help:
https://docs.github.com - HTML Validator:
https://validator.w3.org - Free Code Resources:
https://www.freecodecamp.org