Replies: 4 comments
-
|
Nice template! For GitHub Pages specifically, the key thing to know is that GitHub Pages automatically serves a 404.html file when a requested resource isn't found. For static site hosting on GitHub Pages, here's what you need to do:
For Jekyll sites (if using Jekyll on GitHub Pages):
Testing locally:
Your HTML and CSS look great! Just make sure the file is committed and pushed to your repository. GitHub Pages should pick it up automatically within a few minutes. Hope this helps! Let me know if you run into any issues with your GitHub Pages setup. |
Beta Was this translation helpful? Give feedback.
-
|
✅ How 404 Works in GitHub Pages If you’re using GitHub Pages, you must place: /404.html 👉 Directly in the root of your published branch (usually main or gh-pages) NOT inside a folder like: 404/404.html ❌ It must be: /404.html ✅ For a basic GitHub Pages site: /index.html If you're using a project repo (username.github.io/repo-name), same rule — 404.html must be at the root of the published branch. You forgot the . before error-container. This: error-container h1 Should be: .error-container h1 Because it's a class. ✅ Fixed style.css .error-container h1 { .error-container p { .error-container a { .error-container a:hover { |
Beta Was this translation helpful? Give feedback.
-
|
To create a custom 404 page in GitHub Pages, you simply need to place a file named 404.html in the root directory of your repository (not inside a separate 404 folder). After committing and pushing it to GitHub, GitHub Pages will automatically serve this file whenever someone visits a non-existent URL on your site. No server configuration is required. Also, make sure your CSS selectors are correct (for example, use .error-container instead of error-container) so the styling works properly. |
Beta Was this translation helpful? Give feedback.
-
|
put it in the root of the repo |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Show & Tell
Body
How to create a 404 page in GitHub Pages?
File Path:
Code:
404.html
style.css
Testing the Page
Save the files as 404.html and style.css.
Configure your web server (Apache, Nginx, or hosting provider) to serve this file for 404 errors.
Visit a non-existent URL on your site to verify it loads correctly.
Best Practices
Keep the design consistent with your site’s branding.
Include navigation links or a search bar to help users find content.
Make it mobile-friendly for better accessibility.
Optionally add creative visuals or animations for engagement.
Beta Was this translation helpful? Give feedback.
All reactions