Skip to content

Commit 4ad1223

Browse files
committed
Enhance GitHub Pages setup and improve index.html redirection
- Updated README.md to clarify the custom domain setup and its potential issues. - Modified pages.yml to include 404.html in the deployment for better error handling. - Improved index.html to use JavaScript for redirection, with a fallback meta refresh for users without JavaScript enabled, and enhanced the page's styling and content for better user experience.
1 parent 48b46d9 commit 4ad1223

4 files changed

Lines changed: 35 additions & 7 deletions

File tree

.github/workflows/pages.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ jobs:
4040
cp playground.html _site/
4141
cp -r topics _site/
4242
cp site/index.html _site/index.html
43+
cp site/404.html _site/404.html
44+
touch _site/.nojekyll
4345
4446
- uses: actions/configure-pages@v5
4547

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ make run TOPIC=01_hello_world/hello_world
5858

5959
Run the same examples in the browser (edit, **Run**, optional live JSCPP + baked `gcc` output):
6060

61-
**[C Playground (GitHub Pages)](https://chama-x.github.io/C-Learning-Library/playground.html)** · [site root (redirect)](https://chama-x.github.io/C-Learning-Library/)
61+
**[C Playground (GitHub Pages)](https://chama-x.github.io/C-Learning-Library/playground.html)** · [site root](https://chama-x.github.io/C-Learning-Library/) (redirects into the app)
6262

6363
**One-time setup (repo owner):** In the repo, [Settings → Pages](https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow)**Build and deployment** → Source: **GitHub Actions**, then save. (GitHub does not allow the workflow token to create the site by itself.) After that, push to `main` or re-run the **Pages** workflow from the Actions tab.
6464

65+
**Custom domain looks broken?** If **Settings → Pages → Custom domain** is set (e.g. `chamaththiwanka.me`), GitHub sends all traffic there. If DNS or HTTPS is not set up correctly, the site can show a blank page, “Redirecting…”, or a connection error. Fix: [verify DNS for GitHub Pages](https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site) and turn on **Enforce HTTPS**, or **clear the custom domain** so `https://chama-x.github.io/C-Learning-Library/` loads the app directly.
66+
6567
**What CI checks on every push / PR**
6668

6769
| Check | Meaning |
@@ -135,7 +137,7 @@ Run the same examples in the browser (edit, **Run**, optional live JSCPP + baked
135137
```
136138
topics/01_hello_world/ … 08_structs/ ← .c files + previews/
137139
scripts/ ← run_all, preview helpers, verify_playground_manifest.py
138-
site/ ← index.html for GitHub Pages root
140+
site/ ← index.html + 404.html for GitHub Pages
139141
.github/workflows/ci.yml ← build + manifest checks (every PR/push)
140142
.github/workflows/pages.yml ← deploy to GitHub Pages (after Pages enabled)
141143
bin/ ← compiled binaries (git-ignored)

site/404.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>Page not found — C Playground</title>
7+
<script>location.replace("playground.html"+(location.search||"")+(location.hash||""));</script>
8+
<noscript><meta http-equiv="refresh" content="0;url=playground.html"></noscript>
9+
</head>
10+
<body style="font-family:system-ui,sans-serif;background:#0d0d12;color:#e0e0ef;padding:2rem">
11+
<p><a href="playground.html" style="color:#7c72f0">Open C Playground →</a></p>
12+
</body>
13+
</html>

site/index.html

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,22 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1">
6-
<meta http-equiv="refresh" content="0;url=playground.html">
7-
<title>C Playground</title>
8-
<link rel="canonical" href="./playground.html">
6+
<title>C Playground — C Learning Library</title>
7+
<link rel="canonical" href="playground.html">
8+
<script>
9+
(function () {
10+
var q = location.search || "";
11+
var h = location.hash || "";
12+
location.replace("playground.html" + q + h);
13+
})();
14+
</script>
15+
<noscript>
16+
<meta http-equiv="refresh" content="0;url=playground.html">
17+
</noscript>
918
</head>
10-
<body style="font-family:system-ui,sans-serif;background:#0d0d12;color:#888;padding:2rem;">
11-
<p><a href="playground.html" style="color:#7c72f0">Open C Playground →</a></p>
19+
<body style="font-family:system-ui,sans-serif;background:#0d0d12;color:#e0e0ef;padding:2rem;line-height:1.6">
20+
<h1 style="font-size:1.25rem;font-weight:600;margin:0 0 0.5rem">C Playground</h1>
21+
<p style="color:#8080a0;margin:0 0 1rem">If you are not redirected automatically, open the app below.</p>
22+
<p><a href="playground.html" style="color:#7c72f0;font-weight:500">Open C Playground →</a></p>
1223
</body>
1324
</html>

0 commit comments

Comments
 (0)