Recall & Review
beginner
What is the purpose of the
public directory in Astro projects?The
public directory holds static files like images, fonts, or icons that are served directly without processing. These files are accessible via the root URL in the browser.Click to reveal answer
beginner
How do you reference a file named
logo.png inside the public directory in your Astro component?You reference it with a root-relative path like
/logo.png. For example, <img src="/logo.png" alt="Logo" />.Click to reveal answer
beginner
True or False: Files inside the
public directory are processed by Astro's build pipeline.False. Files in the
public directory are served as-is without any build processing or bundling.Click to reveal answer
intermediate
Why should you use the
public directory for static assets instead of importing them in Astro components?Using the
public directory is simpler for assets that don't need processing or bundling. It keeps them separate and ensures they are served quickly and directly.Click to reveal answer
intermediate
What happens if you place a file outside the
public directory and try to access it via a URL in Astro?Files outside the
public directory are not served directly. They need to be imported or processed by Astro. Trying to access them via URL will result in a 404 error.Click to reveal answer
Where should you put images that you want to serve directly in an Astro project?
✗ Incorrect
Static assets like images should be placed in the
public directory to be served directly.How do you reference a static file named
icon.svg inside the public directory in your HTML?✗ Incorrect
Files in the
public directory are referenced with a root slash, like /icon.svg.What happens to files inside the
public directory during Astro's build process?✗ Incorrect
Files in
public are copied directly without changes.If you want to serve a font file directly, where should you place it in an Astro project?
✗ Incorrect
Fonts to be served directly should go in the
public directory.True or False: You can import images from the
public directory using JavaScript import statements in Astro.✗ Incorrect
Files in
public are not imported; they are referenced by URL.Explain how the
public directory works in Astro and why it is important for static assets.Think about how you want your images or fonts to be available in the browser.
You got /4 concepts.
Describe how to reference a static asset from the
public directory inside an Astro component.How do you write the URL in HTML to access a file in public?
You got /4 concepts.