Public
In the larger context of the project structure, the public/ directory serves as the uncompiled static asset repository. Unlike source files inside src/, assets placed in public/ bypass Astro’s build pipeline transformations and are served directly at the root path (/) of the website.
- Contents and Purpose of
public/
The public/ directory stores raw files that must maintain fixed filenames and public URL paths:
- Profile & Branding Media: Stores profile photos such as
public/profile.webpand social link preview cards such aspublic/social_img.webp. - Site Meta Files: Houses root-level files like favicons and
robots.txt.
- Integration into Component Markup & Layouts
Files inside public/ can be referenced directly within .astro components without relative directory paths:
- Sidebar Profile Image:
src/components/SideBar.astroreferences/profile.webpto display the personal photo in the persistent navigation bar. - Social Sharing Preview: Meta headers in global layout files reference
/social_img.webpfor Open Graph and Twitter card link previews.
- Compilation & Docker Deployment Lifecycle
During compilation and deployment, public/ assets follow a simple static transfer path:
- Build Compilation Stage: When running
npm run buildorpnpm run build(Stage 1 of the Dockerfile), Astro copies all files frompublic/straight into the root of the output distribution folder (/app/dist/ordist/). - Production Serving: In Stage 2 of the multi-stage Docker build, Caddy or Nginx copies
/app/distinto its serving directory (/usr/share/caddyor/usr/share/nginx/html) and serves those static files directly over HTTP on port 80.