Performance: Project structure overview
This affects the initial page load speed and developer efficiency by organizing files for optimal build and caching.
src/components/Header.astro
src/components/Footer.astro
src/pages/index.astro
src/utils/helpers.js
public/assets/images/logo.png
// Clear separation of components, pages, utils, and public assetssrc/components/Header.astro
src/components/Footer.astro
src/pages/index.astro
src/utils/helpers.js
src/assets/images/logo.png
// All files mixed in one folder without separation| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Mixed file structure | N/A | N/A | N/A | [X] Bad |
| Organized file structure | N/A | N/A | N/A | [OK] Good |
src/ folder is where you put your source code like components, pages, and styles.public/ folder is for static files like images, not code.src/ -> Option Asrc/ [OK]src/, static files in public/ [OK]public/ with src/assets/ is default code folderdist/ holds source codepublic/ folder inside an Astro component?public/ files are servedpublic/ are served from the root URL, so you reference them with a leading slash./images/photo.jpg correctly points to public/images/photo.jpg.project/ āā public/ ā āā logo.png āā src/ ā āā components/ ā āā Header.astro āā src/pages/index.astro
logo.png inside Header.astro?public/ files are servedpublic/ are served from the root URL, so you use a root-relative path starting with '/'./logo.png correctly points to the image regardless of component location.public/ folderCannot find module './public/image.png'public/ are not imported via relative paths in code; they are referenced by URL paths.public/ using a relative import causes this error.public/ using a relative import -> Option Bpublic/; use URL paths [OK]public/ inside src/public/ files are bundled like code/about. Where should you place the new file in the project structure?src/pages/ map directly to site URLs.about.astro inside src/pages/ creates the /about route.src/pages/about.astro -> Option Asrc/pages/ folder [OK]src/pages/ for routing [OK]src/components/src/ without pages folderpublic/ folderPass the test and this pattern moves unknown