What will be the correct way to display logo.png inside Header.astro?
medium
A. <img src="src/public/logo.png" alt="Logo" />
B. <img src="../public/logo.png" alt="Logo" />
C. <img src="./logo.png" alt="Logo" />
D. <img src="/logo.png" alt="Logo" />
Solution
Step 1: Recall how public/ files are served
Files in public/ are served from the root URL, so you use a root-relative path starting with '/'.
Step 2: Apply correct path in component
Using /logo.png correctly points to the image regardless of component location.
Final Answer:
<img src="/logo.png" alt="Logo" /> -> Option D
Quick Check:
Public files use root-relative paths [OK]
Hint: Always use root-relative paths for public folder files [OK]
Common Mistakes:
Trying to use relative paths to public/ folder
Including 'public' in the path
Using relative paths that break on deployment
4. You see this error when running your Astro project: Cannot find module './public/image.png' What is the likely cause based on Astro's project structure?
medium
A. The src/ folder is missing
B. Trying to import a static file from public/ using a relative import
C. The public/ folder is inside src/
D. The image file is corrupted
Solution
Step 1: Understand how static files are accessed
Static files in public/ are not imported via relative paths in code; they are referenced by URL paths.
Step 2: Identify the error cause
Trying to import a file from public/ using a relative import causes this error.
Final Answer:
Trying to import a static file from public/ using a relative import -> Option B
Quick Check:
Static files are referenced by URL, not imported [OK]
Hint: Never import files from public/; use URL paths [OK]
Common Mistakes:
Importing images or static files as modules
Placing public/ inside src/
Assuming public/ files are bundled like code
5. You want to add a new page to your Astro site at URL /about. Where should you place the new file in the project structure?
hard
A. src/pages/about.astro
B. public/about/index.html
C. src/components/about.astro
D. src/about.astro
Solution
Step 1: Understand Astro's page routing
Files inside src/pages/ map directly to site URLs.
Step 2: Choose correct location for new page
Placing about.astro inside src/pages/ creates the /about route.
Final Answer:
src/pages/about.astro -> Option A
Quick Check:
Pages go in src/pages/ folder [OK]
Hint: Put new pages in src/pages/ for routing [OK]
Common Mistakes:
Placing pages in src/components/
Adding pages directly in src/ without pages folder
Putting pages in public/ folder
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.