Overview - Public directory for static assets
What is it?
In Astro, the public directory is a special folder where you put static files like images, fonts, or icons. These files are served directly to the browser without any processing or changes. This means you can link to them easily in your website using simple URLs. It helps keep your static assets organized and accessible.
Why it matters
Without a public directory, managing static files would be confusing and error-prone. You might have to copy files manually or write complex code to serve them. The public directory solves this by providing a clear place for assets that never change, making your site faster and easier to build. It also ensures your images and files load correctly for visitors.
Where it fits
Before learning about the public directory, you should understand basic Astro project structure and how web servers deliver files. After this, you can learn about advanced asset optimization and deployment strategies to make your site even faster.
to show images stored in the public folder. The leading slash means the file is served from the root of your website, matching the public directory structure.
(with large-photo.jpg in public)