A 404 page shows up when a user tries to visit a page that does not exist. It helps users know the page is missing and guides them back to useful parts of the site.
Click to reveal answer
beginner
How do you create a custom 404 page in Astro?
Create a file named 404.astro in the src/pages folder. Astro will automatically use it when a page is not found.
Click to reveal answer
intermediate
What is the difference between a 404 page and an error page in Astro?
A 404 page handles 'page not found' errors. An error page handles other server or application errors like 500 (internal server error). Astro can use src/pages/[...].astro or custom error handling for these.
Click to reveal answer
beginner
Why should error pages be user-friendly and accessible?
User-friendly error pages help users understand what went wrong and how to continue. Accessibility ensures all users, including those using screen readers or keyboards, can navigate and understand the message.
Click to reveal answer
beginner
How can you test your 404 page in Astro during development?
Try visiting a URL that does not exist in your local Astro dev server. The custom 404 page should appear automatically.
Click to reveal answer
What filename should you use to create a custom 404 page in Astro?
A404.astro
Berror.astro
Cnotfound.astro
Dpage404.astro
✗ Incorrect
Astro uses the file named 404.astro in the pages folder to show the 404 page.
What HTTP status code does a 404 page represent?
A404
B200
C500
D301
✗ Incorrect
404 means the page was not found on the server.
Which folder should your 404.astro file be placed in for Astro to recognize it?
Asrc/components
Bsrc/pages
Csrc/layouts
Dpublic
✗ Incorrect
Astro looks for pages inside src/pages, including 404.astro.
Why is it important to include navigation links on your 404 page?
ATo confuse users
BTo hide the error
CTo increase page load time
DTo help users find their way back to working pages
✗ Incorrect
Navigation links guide users back to useful parts of the site after a 404 error.
Which of these is NOT a good practice for error pages?
AClear message about the error
BAccessible design for all users
CDetailed technical error logs shown to users
DLinks to homepage or help
✗ Incorrect
Showing technical error logs can confuse users and expose sensitive info.
Explain how to set up a custom 404 page in Astro and why it is important.
Think about file location and user guidance.
You got /4 concepts.
Describe the difference between a 404 page and a general error page in Astro.
Consider types of errors and how Astro handles them.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a 404.astro page in an Astro project?
easy
A. To speed up the loading of the homepage
B. To display the site map automatically
C. To handle user login and authentication
D. To show a friendly message when a user visits a page that does not exist
Solution
Step 1: Understand the role of 404 pages
A 404 page appears when a user tries to visit a page that the website cannot find.
Step 2: Identify the purpose in Astro
In Astro, 404.astro is used to show a friendly message for missing pages.
Final Answer:
To show a friendly message when a user visits a page that does not exist -> Option D
Quick Check:
404 page = friendly missing page message [OK]
Hint: 404 pages show missing page messages [OK]
Common Mistakes:
Thinking 404 pages speed up the homepage
Confusing 404 pages with login pages
Assuming 404 pages show site maps
2. Which file name should you create in an Astro project to automatically handle 404 errors?
easy
A. error.astro
B. notfound.astro
C. 404.astro
D. page404.astro
Solution
Step 1: Recall Astro's naming convention for 404 pages
Astro uses the exact file name 404.astro to detect and serve 404 error pages automatically.
Step 2: Compare options with the required file name
Only 404.astro matches the required name; others won't be recognized automatically.
Final Answer:
404.astro -> Option C
Quick Check:
404 page file = 404.astro [OK]
Hint: Use exact file name 404.astro for error pages [OK]
Common Mistakes:
Using names like error.astro or notfound.astro
Adding prefixes or suffixes to 404 file name
Assuming any file with '404' works
3. Given this 404.astro code snippet, what will the user see when visiting a missing page?
<!-- 404.astro -->
<h1>Oops! Page not found.</h1>
<p>Try going back to the <a href='/'>homepage</a>.</p>
medium
A. A blank page with no message
B. A message saying 'Oops! Page not found.' with a link to homepage
C. An error message with code 500
D. The homepage content without any error message
Solution
Step 1: Read the 404.astro content
The code shows a heading with 'Oops! Page not found.' and a paragraph with a homepage link.
Step 2: Understand what Astro renders on missing pages
Astro will display this content when a user visits a missing page.
Final Answer:
A message saying 'Oops! Page not found.' with a link to homepage -> Option B
Quick Check:
404 page shows friendly message + homepage link [OK]
Hint: 404 page content shows on missing pages [OK]
Common Mistakes:
Expecting a blank page instead of message
Confusing 404 with server error 500
Thinking homepage content shows on 404
4. You created a 404.astro page but it does not show when visiting a missing page. What is the most likely mistake?
medium
A. The 404.astro file is inside the src/components folder
B. The file is named 404.html instead of 404.astro
C. The homepage link is missing inside the 404 page
D. The project does not have a package.json file
Solution
Step 1: Check file location requirements in Astro
Astro expects 404.astro to be in the root of the src/pages folder, not inside components.