To run your HTML, CSS, and JavaScript files on GitHub Pages, follow these steps:
1. Ensure Proper File Structure
Your repository must have these files in the root directory:
yourusername.github.io/
├── index.html <-- Entry point
├── styles.css <-- CSS file
├── script.js <-- JavaScript file
├── assets/ <-- (Optional) Folder for images/fonts
└── CNAME <-- (Optional) For custom domain
2. Deploy to GitHub Pages
A. Push Code to GitHub
# Navigate to your project folder
cd your-project-folder
# Add all files
git add .
# Commit with a message
git commit -m "Deploy portfolio website"
# Push to GitHub
git push -u origin main
B. Verify Deployment
- Go to your GitHub repository:
https://github.com/yourusername/yourusername.github.io
- Check the Actions tab to see if the deployment succeeded.
- Visit your site:
https://yourusername.github.io
3. Troubleshooting Common Issues
🔍 Page Not Found
- Ensure
index.html is in the root directory (not a subfolder like /src).
- Check for typos in filenames (e.g.,
index.html vs Index.html).
🔍 CSS/JS Not Loading
- Verify file paths in your HTML:
<!-- Correct path for CSS -->
<link rel="stylesheet" href="styles.css">
<!-- Correct path for JS -->
<script src="script.js"></script>
- Use absolute paths if files are in subfolders:
<link rel="stylesheet" href="/styles.css">
<script src="/script.js"></script>
🔍 JavaScript Errors
Check the browser console for errors:
- Right-click → Inspect → Console tab.
- Fix issues like:
- Typos in variable/function names.
- Missing DOM elements (e.g.,
document.getElementById("menu-toggle") but no element with id="menu-toggle").
4. Force Refresh GitHub Pages
If changes aren’t visible:
- Clear your browser cache (Ctrl + F5 or Cmd + Shift + R).
- Append a query parameter to bypass cache:
https://yourusername.github.io?cachebust=123
5. Check GitHub Pages Settings
- Go to your repository → Settings → Pages.
- Under Build and deployment:
- Source:
Deploy from a branch.
- Branch:
main (or master if using an older repo).
- Ensure no build errors are reported.
6. Example Workflow
If your files are structured like this:
priteshparab/
├── index.html
├── styles.css
└── script.js
After pushing, your site will be live at:
https://parabpritesh.github.io/priteshparab/
7. Verify with GitHub Actions
- Go to your repository → Actions tab.
- Check the latest workflow run.
✅ Success means deployment worked.
❌ Failure means check logs for errors.
Still stuck?
- Share your repository URL.
- Describe the exact issue (e.g., "page not found" or "JS not working").
- I’ll help debug! 🛠️