-
-
Notifications
You must be signed in to change notification settings - Fork 249
Add default error.hbs and error-404.hbs templates #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| {{!< default}} | ||
|
|
||
| {{!-- | ||
| 404 page. Inherits the default layout so visitors keep the theme's | ||
| navigation, footer, and overall look while they figure out where to go. | ||
| --}} | ||
|
|
||
| <main class="gh-main"> | ||
|
|
||
| <article class="gh-article gh-canvas"> | ||
|
|
||
| <header class="gh-article-header"> | ||
| <h1 class="gh-article-title is-title">{{statusCode}}</h1> | ||
| <p class="gh-article-excerpt is-body">{{t "Page not found"}}</p> | ||
| </header> | ||
|
|
||
| <section class="gh-content is-body"> | ||
| <p> | ||
| <a href="{{@site.url}}" class="gh-button">{{t "Go to the front page →"}}</a> | ||
| </p> | ||
| </section> | ||
|
|
||
| </article> | ||
|
|
||
| </main> | ||
|
|
||
| {{!-- Visitors landing here didn't find what they were looking for. | ||
| Suggest a few recent posts to help them re-engage. --}} | ||
| {{#get "posts" include="authors" limit="3" as |suggested|}} | ||
| {{#if suggested}} | ||
| <section class="gh-container is-grid gh-outer"> | ||
| <div class="gh-container-inner gh-inner"> | ||
| <h2 class="gh-container-title">{{t "Recent posts"}}</h2> | ||
| <main class="gh-main"> | ||
| <div class="gh-feed"> | ||
| {{#foreach suggested}} | ||
| {{> "post-card" lazyLoad=true}} | ||
| {{/foreach}} | ||
| </div> | ||
| </main> | ||
| </div> | ||
| </section> | ||
| {{/if}} | ||
| {{/get}} | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,66 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {{!-- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Generic error template — handles all non-404 errors (500, etc.). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Standalone (doesn't extend default.hbs) and kept lightweight on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| purpose: minimal dependencies, no partials, no API calls. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The reasoning mirrors Casper's: 500 errors usually happen when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| something on the server is struggling, so we don't want the error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| page itself to compound the issue. Keep this template as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self-contained as possible. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <!DOCTYPE html> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <html lang="{{@site.locale}}"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <head> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <title>{{meta_title}}</title> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <meta charset="utf-8"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <link rel="stylesheet" type="text/css" href="{{asset "built/screen.css"}}"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <style> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| :root { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --background-color: {{@custom.site_background_color}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </style> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {{ghost_head}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </head> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <body class="{{body_class}}"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+19
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing contrast-class handling can make error text unreadable on custom backgrounds.
Suggested fix <body class="{{body_class}}">
+<script>
+ var accentColor = getComputedStyle(document.documentElement).getPropertyValue('--background-color').trim().slice(1);
+ if (accentColor.length === 3) {
+ accentColor = accentColor[0] + accentColor[0] + accentColor[1] + accentColor[1] + accentColor[2] + accentColor[2];
+ }
+ var r = parseInt(accentColor.substr(0, 2), 16);
+ var g = parseInt(accentColor.substr(2, 2), 16);
+ var b = parseInt(accentColor.substr(4, 2), 16);
+ var yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
+ document.documentElement.className = `has-${yiq >= 128 ? 'dark' : 'light'}-text`;
+</script>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <main class="gh-main"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <article class="gh-article gh-canvas"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <header class="gh-article-header"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <h1 class="gh-article-title is-title">{{statusCode}}</h1> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <p class="gh-article-excerpt is-body">{{message}}</p> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </header> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <section class="gh-content is-body"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <p> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <a href="{{@site.url}}" class="gh-button">{{t "Go to the front page →"}}</a> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In Useful? React with 👍 / 👎. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </p> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </section> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {{#if errorDetails}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <section class="gh-content is-body"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <h3>{{t "Theme errors"}}</h3> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ul> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {{#foreach errorDetails}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <li> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <strong>{{rule}}</strong> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {{#foreach failures}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <p>{{ref}}: {{message}}</p> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {{/foreach}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </li> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {{/foreach}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </ul> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </section> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {{/if}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </article> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </main> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {{ghost_foot}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </body> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </html> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: TryGhost/Source
Length of output: 164
🏁 Script executed:
Repository: TryGhost/Source
Length of output: 137
🏁 Script executed:
Repository: TryGhost/Source
Length of output: 1786
🏁 Script executed:
Repository: TryGhost/Source
Length of output: 164
Avoid a second
<main>landmark inerror-404.hbserror-404.hbsalready has a<main class="gh-main">at the top, and lines 34-40 add another<main class="gh-main">around the “Recent posts” feed, creating landmark ambiguity for screen readers. Switch the inner wrapper to a non-landmark element while keeping the styling class.♻️ Proposed fix
🤖 Prompt for AI Agents