Start an Astro project
Choose src or public for an asset
Put processed project assets under src and reserve public for files that must keep their exact name and bytes.
8 minute lesson
Choose an asset location from how the file should be built.
A public file keeps its name and bytes:
public/favicon.svg → /favicon.svg
public/downloads/guide.pdf → /downloads/guide.pdf
Reference it by its root URL. Do not write /public/ in the browser URL.
A source asset can be imported:
---
import diagram from '../assets/request-flow.png'
---
Astro can check that the file exists, fingerprint the output, and process it through the asset pipeline.
Use public/ when an exact path matters or processing is unwanted. Use src/ for project images, scripts, and styles that benefit from imports, optimization, and build errors.
A broken public URL may survive the build because it is only a string. A broken source import fails early. That feedback is valuable.
Rename one public file and one imported source file. Compare when each mistake is reported.
Lesson completed