Bird
Raised Fist0
Astroframework~5 mins

Project structure overview in Astro - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What is the purpose of the src folder in an Astro project?
The src folder holds all the source files like pages, components, and layouts that make up your website. It's where you write your code.
Click to reveal answer
beginner
What does the public folder contain in an Astro project?
The public folder stores static files like images, fonts, and icons. These files are served directly to the browser without processing.
Click to reveal answer
intermediate
Why is the astro.config.mjs file important?
It configures your Astro project settings like build options, integrations, and site metadata. Think of it as the project’s control center.
Click to reveal answer
beginner
What role do the components inside src play?
Components are reusable pieces of UI like buttons or headers. They help keep your code organized and avoid repetition.
Click to reveal answer
beginner
Where do you put your page files in an Astro project?
Page files go inside the src/pages folder. Each file corresponds to a route on your website, like a page you visit.
Click to reveal answer
Which folder in Astro holds your reusable UI parts?
Asrc/pages
Bpublic
Cnode_modules
Dsrc/components
Where do you place images that should be served directly without processing?
Apublic
Bsrc/components
Csrc/pages
Dsrc/assets
What does each file inside src/pages represent?
AA reusable UI component
BA configuration setting
CA website page or route
DA static asset
Which file controls build options and integrations in Astro?
Aastro.config.mjs
Bpackage.json
CREADME.md
Dsrc/components/Button.astro
If you want to add a new page to your site, where do you add the file?
Apublic
Bsrc/pages
Csrc/components
Dsrc/layouts
Describe the main folders in an Astro project and what each is used for.
Think about where you put your code, images, pages, and settings.
You got /5 concepts.
    Explain how Astro organizes pages and components in the project structure.
    Consider how you build a website from pages and smaller parts.
    You got /3 concepts.

      Practice

      (1/5)
      1. In an Astro project, which folder is primarily used to store your source code like components and pages?
      easy
      A. src/
      B. public/
      C. assets/
      D. dist/

      Solution

      1. Step 1: Understand folder roles in Astro

        The src/ folder is where you put your source code like components, pages, and styles.
      2. Step 2: Identify the correct folder for code

        The public/ folder is for static files like images, not code.
      3. Final Answer:

        src/ -> Option A
      4. Quick Check:

        Source code folder = src/ [OK]
      Hint: Code lives in src/, static files in public/ [OK]
      Common Mistakes:
      • Confusing public/ with src/
      • Thinking assets/ is default code folder
      • Assuming dist/ holds source code
      2. Which of the following is the correct way to reference a static image stored in the public/ folder inside an Astro component?
      easy
      A. <img src="../src/images/photo.jpg" />
      B. <img src="src/images/photo.jpg" />
      C. <img src="/images/photo.jpg" />
      D. <img src="./public/images/photo.jpg" />

      Solution

      1. Step 1: Understand how public/ files are served

        Files in public/ are served from the root URL, so you reference them with a leading slash.
      2. Step 2: Choose the correct path format

        Using /images/photo.jpg correctly points to public/images/photo.jpg.
      3. Final Answer:

        <img src="/images/photo.jpg" /> -> Option C
      4. Quick Check:

        Static files use root-relative paths [OK]
      Hint: Static files use root-relative paths starting with '/' [OK]
      Common Mistakes:
      • Using relative paths like 'src/images' for public files
      • Including 'public/' in the path
      • Using relative paths that don't work in deployed site
      3. Given this Astro project structure:
      project/
      ├─ public/
      │  └─ logo.png
      ├─ src/
      │  └─ components/
      │     └─ Header.astro
      └─ src/pages/index.astro

      What will be the correct way to display logo.png inside Header.astro?
      medium
      A. <img src="src/public/logo.png" alt="Logo" />
      B. <img src="../public/logo.png" alt="Logo" />
      C. <img src="./logo.png" alt="Logo" />
      D. <img src="/logo.png" alt="Logo" />

      Solution

      1. Step 1: Recall how public/ files are served

        Files in public/ are served from the root URL, so you use a root-relative path starting with '/'.
      2. Step 2: Apply correct path in component

        Using /logo.png correctly points to the image regardless of component location.
      3. Final Answer:

        <img src="/logo.png" alt="Logo" /> -> Option D
      4. Quick Check:

        Public files use root-relative paths [OK]
      Hint: Always use root-relative paths for public folder files [OK]
      Common Mistakes:
      • Trying to use relative paths to public/ folder
      • Including 'public' in the path
      • Using relative paths that break on deployment
      4. You see this error when running your Astro project:
      Cannot find module './public/image.png'
      What is the likely cause based on Astro's project structure?
      medium
      A. The src/ folder is missing
      B. Trying to import a static file from public/ using a relative import
      C. The public/ folder is inside src/
      D. The image file is corrupted

      Solution

      1. Step 1: Understand how static files are accessed

        Static files in public/ are not imported via relative paths in code; they are referenced by URL paths.
      2. Step 2: Identify the error cause

        Trying to import a file from public/ using a relative import causes this error.
      3. Final Answer:

        Trying to import a static file from public/ using a relative import -> Option B
      4. Quick Check:

        Static files are referenced by URL, not imported [OK]
      Hint: Never import files from public/; use URL paths [OK]
      Common Mistakes:
      • Importing images or static files as modules
      • Placing public/ inside src/
      • Assuming public/ files are bundled like code
      5. You want to add a new page to your Astro site at URL /about. Where should you place the new file in the project structure?
      hard
      A. src/pages/about.astro
      B. public/about/index.html
      C. src/components/about.astro
      D. src/about.astro

      Solution

      1. Step 1: Understand Astro's page routing

        Files inside src/pages/ map directly to site URLs.
      2. Step 2: Choose correct location for new page

        Placing about.astro inside src/pages/ creates the /about route.
      3. Final Answer:

        src/pages/about.astro -> Option A
      4. Quick Check:

        Pages go in src/pages/ folder [OK]
      Hint: Put new pages in src/pages/ for routing [OK]
      Common Mistakes:
      • Placing pages in src/components/
      • Adding pages directly in src/ without pages folder
      • Putting pages in public/ folder
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard