Complete the code to create a basic 404 page in Astro.
--- export const prerender = true; --- <html lang="en"> <head> <title>Page Not Found</title> </head> <body> <h1>404 - [1]</h1> <p>Sorry, the page you are looking for does not exist.</p> </body> </html>
The standard message for a 404 page is "Not Found" to indicate the page is missing.
Complete the code to export a custom 404 component in Astro.
--- export const prerender = true; export function [1]() { return ( <html lang="en"> <head><title>404 Not Found</title></head> <body> <h1>Page Not Found</h1> </body> </html> ); } ---
In Astro, a custom 404 page component is often named NotFound for clarity.
Fix the error in the Astro 404 page code by completing the missing export.
--- [1] = true; --- <html lang="en"> <head><title>404 Not Found</title></head> <body> <h1>Oops! Page not found.</h1> </body> </html>
To enable prerendering in Astro, you must export prerender as a constant.
Fill both blanks to create a custom error page component with a status code and message.
--- export function [1]({ status }) { return ( <html lang="en"> <head><title>Error [2]</title></head> <body> <h1>Error {status}</h1> <p>Something went wrong.</p> </body> </html> ); } ---
The function is named ErrorPage to represent a generic error page, and the status code 500 is used for server errors.
Fill all three blanks to create a 404 page with a link back to the homepage.
--- export const prerender = true; --- <html lang="en"> <head> <title>[1] Not Found</title> </head> <body> <h1>404 - [2]</h1> <p>The page you requested could not be found.</p> <a href="[3]" aria-label="Go back to homepage">Go Home</a> </body> </html>
The title uses "Page Not Found", the heading uses "Not Found", and the link points to the homepage at "/".
