Chapter 02 • Lesson 2.10

File Organization & Project Structure

Architect robust, scalable folder hierarchies for web projects. Learn standard asset categorization, master kebab-case naming rules, prevent case-sensitivity bugs, and navigate relative directory traversals like a pro.

🎯 Learning Objectives

📖 Mental Model: The City Library Classification System

If a massive metropolitan library dumped 500,000 books into one giant pile in the lobby, finding a specific volume on astronomy would be impossible. Instead, books are sorted into distinct wings, floors, shelves, and call numbers with a universal index catalog at the front door.

Your Project Structure is your digital library. index.html is the front lobby desk. The assets/ folder is the media archive divided into books (CSS), maps (images), and audio recordings (JS). Relative paths are the clear walking directions from one room to another.

🎬 INTERACTIVE VISUAL PIPELINE 2.10 Project Structure & File Organization
🌐
1. Input
Directives & Tags
⚙️
2. Parse
Tokenizer & AST
🌳
3. Layout
Box Model & Flow
🎨
4. Render
GPU Paint & Composite
PHASE 1: INPUT & DIRECTIVES
Browser receives declarative markup stream, parsing tag tokens and initializing component state.

Standard Production Project Layout

Every professional static web project follows a structured root layout:

my-web-project/ ├── index.html ← Primary homepage entry point (served automatically by web servers) ├── .gitignore ← Files excluded from Git version control ├── README.md ← Documentation, installation, and setup instructions │ ├── pages/ ← Secondary subpages │ ├── about.html │ ├── services.html │ └── contact.html │ └── assets/ ← Static media & resource files ├── css/ │ ├── /assets/css/main.css?v=2.1 ← Main stylesheet │ └── normalize.css ← Cross-browser reset styles ├── js/ │ ├── app.js ← Main script │ └── modules/ ← Modular helper scripts ├── images/ │ ├── icons/ ← UI icons (.svg, .png) │ └── hero-banner.webp← Compressed photos and graphics └── fonts/ ← Custom web fonts (.woff2)

Why index.html is Mandatory at Root

When a user visits https://example.com/, the web server looks for a default index document. By global HTTP server convention (Apache, Nginx, Cloudflare, GitHub Pages), index.html is automatically served without requiring the filename in the URL bar.

Strict File Naming Rules

Breaking file naming conventions is the #1 cause of broken images and 404 errors when deploying from local machines to production:

Convention Rule ❌ Broken / Bad Example ✅ Production-Ready Standard Why It Matters
Strict Lowercase AboutUs.HTML
HeroImage.PNG
about-us.html
hero-image.png
Windows and macOS file systems are case-insensitive, but Linux production web servers are strictly case-sensitive. Logo.png will 404 on Linux if linked as logo.png!
Kebab-Case Hyphens my contact form.html my-contact-form.html Spaces in URLs are replaced with ugly %20 escape codes (e.g. my%20contact%20form.html) and frequently break scripts.
No Special Characters price#list$2.html price-list-v2.html Characters like #, ?, &, %, and / have reserved meanings in URL queries and fragments.

Relative Path Traversal Matrix

How you reference a file depends entirely on the location of the current file relative to the target file:

Location Relationship Syntax Example
Same Directory filename.ext or ./filename.ext From index.html referencing a sibling: href="about.html"
Deeper into Child Folder folder/filename.ext From index.html referencing CSS: href="assets/css//assets/css/main.css?v=2.1"
Step Up One Parent Folder ../filename.ext From pages/about.html referencing root index: href="../index.html"
Step Up Two Parent Levels ../../assets/images/logo.png From pages/blog/post-1.html referencing root assets: src="../../assets/images/logo.png"

Live Code Example: Multi-Level Path Traversal UI

In the interactive editor below, observe how breadcrumbs and links reflect directory navigation across root, category, and detail pages:

SYS: ACTIVE
HULL: 98%
CORE: STABLE
NET: ONLINE
HTML STARSHIP CODE TERMINAL path-traversal-demo.html
LIVE RENDER & DIAGNOSTICS CORE TEMP: 45°C
INSPECTING DOM: VALID
TAGS: SCANNING...

🏋️ Hands-On Exercise: Fix Broken Relative Paths

  1. Imagine you are editing the file /projects/web-design/case-study.html (2 levels deep from project root).
  2. Fix the broken links in the markup below:
    • The home button needs to step up 2 directory levels to reach /index.html.
    • The stylesheet link needs to step up 2 levels to reach /assets/css/theme.css.
    • The next project link points to a sibling file in the same folder: mobile-app.html.
  3. Click ▶ Run Code to verify the completed layout.
SYS: ACTIVE
HULL: 98%
CORE: STABLE
NET: ONLINE
HTML STARSHIP CODE TERMINAL exercise-2-10.html
LIVE RENDER & DIAGNOSTICS CORE TEMP: 45°C
INSPECTING DOM: VALID
TAGS: SCANNING...

⚠️ Common Pitfall: Uppercase File Extensions on Linux Servers

If an image file is named profile.JPG on your local Windows laptop, Windows will gladly display it whether your HTML says src="profile.jpg" or src="profile.JPG". But the moment you deploy to Linux web servers (GitHub Pages, Vercel, Netlify), the server will return a 404 Not Found because Linux distinguishes uppercase from lowercase. Always name files in strict all-lowercase!

💡 Pro Tip: Clean URLs with Subfolder Indexes

Instead of naming your contact page contact.html (which results in the URL example.com/contact.html), create a folder named contact/ and place an index.html inside it! The browser URL becomes a sleek, modern, extensionless clean URL: example.com/contact/!

📌 Key Takeaways

⭐ LEARN: HTML 🌟 ⚔️ QUIZ BATTLE ARENA // ACTIVE
3x
STREAK!
BONUS ACTIVE
COMBO
? Question 1 / 3

If you are editing a file located at /blog/2026/article.html, how do you reference an image at /assets/images/hero.jpg?

Question 1 / 3 Topic: HTML Fundamentals
14:28 REMAINING
XP REWARD
+250 XP
3x
STREAK!
BONUS ACTIVE
COMBO
? Question 2 / 3

Why should you avoid spaces in filenames (e.g. my project page.html)?

Question 2 / 3 Topic: HTML Fundamentals
14:28 REMAINING
XP REWARD
+250 XP
3x
STREAK!
BONUS ACTIVE
COMBO
? Question 3 / 3

Why is index.html the standard name for the homepage of a website?

Question 3 / 3 Topic: HTML Fundamentals
14:28 REMAINING
XP REWARD
+250 XP