A website isn't a single file: it's a collection of HTML pages, stylesheets, images, videos and audio files that refer to one another. For those references to work, the browser needs to know where each file is, and that is specified using paths. A badly written path is the most common cause of images that don't appear, styles that aren't applied and broken links. In this lesson you will organise the folder structure for The Blue Cup, learn to name files safely and master relative and absolute paths.

Contents

  1. The project folder structure
  2. Conventions for naming files and folders
  3. index.html: the default page
  4. What a path is
  5. Relative paths: same folder, subfolders and ../
  6. Absolute paths: full URLs and root-relative paths
  7. Comparison and when to use each
  8. Practising with The Blue Cup's pages

The project folder structure

So far your project only has index.html. Let's create the definitive structure you will use throughout the course:

the-blue-cup/
├── index.html          ← home page
├── menu.html           ← menu with prices
├── bookings.html       ← booking form
├── gallery.html        ← images, video and audio
├── news.html           ← blog-style articles
├── contact.html        ← contact details
├── css/
│   └── styles.css      ← stylesheet (Module 8)
├── img/
│   ├── logo.png
│   └── storefront.jpg
└── media/
    ├── intro.mp4
    └── ambience.mp3

The reasoning behind this organisation:

Folder / file What it contains Why it's kept separate
Root (the-blue-cup/) The .html pages They are the addresses the user visits; keeping them in the root gives short URLs
css/ Stylesheets Separating presentation from content
img/ Images (.jpg, .png, .webp, .svg) There are usually lots of them; grouping them makes them easier to find
media/ Video and audio (.mp4, .webm, .mp3) Large files of a different type

In large projects you will come across variations (assets/, js/, fonts/), but the principle is the same: each type of resource in its own folder.

Creating the structure

In VS Code, with the the-blue-cup folder open, use the Explorer's New Folder and New File icons. You can also do it from a terminal (in VS Code: Terminal > New Terminal):

# Run inside the the-blue-cup folder
mkdir css img media
touch menu.html bookings.html gallery.html news.html contact.html
  • mkdir css img media: creates the three subfolders in one go.
  • touch …: creates empty files (on macOS and Linux; in Windows PowerShell use New-Item menu.html, bookings.html, gallery.html, news.html, contact.html).

The new pages will be empty; you will fill them in over the coming modules. You will add the images and media files in Module 3.

Conventions for naming files and folders

File names end up as part of URLs (thebluecup.example/menu.html). A badly chosen name may work on your computer and break when you publish. Recommended rules:

Rule Correct Incorrect Why
All lower case menu.html Menu.html Many servers (Linux) are case-sensitive: Menu.html ≠ menu.html
Hyphens to separate words white-coffee.jpg white coffee.jpg Spaces become %20 in the URL and cause problems
No accents or symbols cafe-menu.html, creme-brulee.jpg café-menu.html, crème-brûlée.jpg Non-ASCII characters are encoded in the URL and some systems handle them badly
Hyphen - rather than underscore _ sourdough-bread.jpg sourdough_bread.jpg Search engines treat the hyphen as a word separator
Descriptive names cafe-storefront.jpg IMG_20260312.jpg You know what it is without opening it, and it helps SEO
Correct extension logo.png logo The server and the browser use the extension to know the file type

The case problem: Windows and macOS are not normally case-sensitive, so img/Logo.png and img/logo.png work the same on your computer. Most web servers run Linux, which is case-sensitive. The classic result: "the image shows up on my computer but not on the server". If everything is in lower case, this problem disappears.

index.html: the default page

When a browser requests a folder rather than a specific file (for example, https://thebluecup.example/), the server looks inside it for a default file and serves that. By convention, that file is index.html.

The user types The server delivers
https://thebluecup.example/ /index.html
https://thebluecup.example/news/ /news/index.html (if that folder existed)
https://thebluecup.example/menu.html /menu.html

That's why The Blue Cup's home page is called index.html: it's what anyone who types just the domain will see. Some considerations:

  • It must be in lower case (Index.html wouldn't work on many servers).
  • Live Server also follows this convention: if you visit http://127.0.0.1:5500/, it will show index.html.
  • If you open files directly with file:///, this behaviour doesn't exist: opening a folder shows a list of files. It's one of the differences between working with and without a server that were mentioned when setting up the environment.

What a path is

A path is the address of a file: it states how to get to it. In HTML, paths are written as the value of certain attributes. For example:

<a href="menu.html">See the menu</a>
<img src="img/logo.png" alt="The Blue Cup logo">
  • <a> creates a link; its href attribute contains the path to the destination.
  • <img> displays an image; its src attribute contains the path to the image file.

In this lesson we use <a> and <img> purely as a vehicle for practising paths. Everything about links and images (destinations, alt, sizes, formats…) is covered in Module 3. Here, focus on the value of href and src.

There are two main families of paths:

graph TD
    R[Paths] --> REL[Relative]
    R --> ABS[Absolute]
    REL --> R1["Same folder: menu.html or ./menu.html"]
    REL --> R2["Subfolder: img/logo.png"]
    REL --> R3["Parent folder: ../index.html"]
    ABS --> A1["Full URL: https://thebluecup.example/menu.html"]
    ABS --> A2["Root-relative: /img/logo.png"]

Relative paths: same folder, subfolders and ../

A relative path describes the route from the file in which it is written. It's like giving someone directions by saying "from where you are, go up one floor and through the second door".

Same folder

If the destination is in the same folder as the current file, its name is enough:

<!-- Inside the-blue-cup/index.html -->
<a href="menu.html">See the menu</a>
<a href="./menu.html">See the menu</a>

Both lines are equivalent. The ./ prefix means "the current folder"; it is optional in HTML, although some people write it to make it clear that the path is relative.

Going down into a subfolder

To go into a subfolder, write its name followed by /:

<!-- Inside the-blue-cup/index.html -->
<img src="img/logo.png" alt="The Blue Cup logo">

This reads: "from the folder containing index.html, go into img and take logo.png". You can chain several levels: img/menu/croissant.jpg.

Going up to the parent folder: ../

The ../ symbol means "go up one level", to the folder that contains the current one. You need it when the file containing the path is inside a subfolder.

Imagine that later on you create a test file for colours inside css/, called css/colour-samples.html, and from it you want to display the logo:

<!-- Inside the-blue-cup/css/colour-samples.html -->
<img src="../img/logo.png" alt="The Blue Cup logo">
<a href="../index.html">Back to home</a>
  • ../img/logo.png: goes up from css/ to the-blue-cup/, into img/ and takes logo.png.
  • ../index.html: goes up to the-blue-cup/ and takes index.html.

You can go up several levels by repeating it: ../../ goes up two.

Visually, the route of ../img/logo.png from css/colour-samples.html is:

graph LR
    A["css/colour-samples.html"] -- "../ (up)" --> B["the-blue-cup/"]
    B -- "img/ (down)" --> C["img/"]
    C --> D["logo.png"]

Note: going up a level will be very common in Module 8, when a stylesheet in css/ needs to refer to images in img/.

Advantages of relative paths

  • The project is portable: you can move the the-blue-cup/ folder to another drive, another computer or a server, and everything keeps working, because the paths depend only on where the files are in relation to one another.
  • They work the same with file:///, with Live Server and once published.

Absolute paths: full URLs and root-relative paths

Full URL

An absolute URL includes everything: protocol, domain and path. It leads to the same place regardless of where it's used.

<a href="https://thebluecup.example/menu.html">The Blue Cup's menu</a>
<a href="https://developer.mozilla.org/en-US/docs/Web/HTML">HTML documentation on MDN</a>

Parts of a URL:

Part In the example Meaning
Protocol (scheme) https:// How the browser communicates with the server
Domain thebluecup.example Which server
Path /menu.html Which file on the server

Use them to link to other websites. For your own files they're a bad idea: if you change domain, or while you're working locally, all the links would point to the published site (or to nothing).

Root-relative paths

A path that starts with / (with no domain) starts from the root of the website, that is, the server's main folder:

<img src="/img/logo.png" alt="The Blue Cup logo">
<a href="/menu.html">Menu</a>
  • /img/logo.png means "from the root of the site, go into img and take logo.png", wherever the file containing the path happens to be.
  • They are convenient on large sites with many folders, because you don't have to work out how many ../ you need.

But they have an important catch during development:

How you open the page What /img/logo.png points to Does it work?
Live Server with the the-blue-cup folder open http://127.0.0.1:5500/img/logo.png Yes
Published at https://thebluecup.example/ https://thebluecup.example/img/logo.png Yes
Double-click (file:///…) The root of the drive: file:///C:/img/logo.png No
Published in a subfolder, e.g. https://hosting.example/the-blue-cup/ https://hosting.example/img/logo.png No

That's why in this course we will use relative paths for all the project's files. That way it will work whether you open the files by double-clicking, with Live Server or once published.

Comparison and when to use each

Type Example Starting point Advantages Disadvantages Recommended use
Relative, same folder menu.html or ./menu.html Current file's folder Simple and portable — Sibling pages
Relative, subfolder img/logo.png Current file's folder Portable Long paths if there are many levels Project resources
Relative, parent folder ../img/logo.png Current file's folder Portable You have to count the levels Files inside subfolders
Root-relative /img/logo.png Root of the site The same from any page Fails with file:/// and in subfolders Large sites always served from the root
Full URL https://thebluecup.example/menu.html None: it's complete Unambiguous Ties the code to a domain Links to other sites

Rule of thumb: your own resources → relative path; external sites → full URL.

Practising with The Blue Cup's pages

Add a few lines to the end of the body in your index.html that link to the other pages. Although links are covered in Module 3, you can already check that the paths work:

    <!-- Temporary links to the other pages (to be improved in Modules 3 and 6) -->
    <p><a href="menu.html">Menu</a></p>
    <p><a href="bookings.html">Bookings</a></p>
    <p><a href="gallery.html">Gallery</a></p>
    <p><a href="news.html">News</a></p>
    <p><a href="contact.html">Contact</a></p>

All the pages are in the same folder as index.html, so the file name is enough. Save, open index.html in the browser and click each link: each page should open (blank for now, because they are empty). Use the Back button to return.

If a link shows a "file not found" error (or a 404 in Live Server), check the file name and the path letter by letter: case, accents and extension.

To check resource paths, you can use the DevTools Network panel: files that can't be found appear in red with the status 404.

Common Mistakes and Tips

  • Windows backslashes (img\logo.png): on the web you always use the forward slash /.
  • Hard drive paths (C:\Users\anna\the-blue-cup\img\logo.png or file:///C:/…): they only work on your computer. When you publish, they all break.
  • Forgetting ../ from a file in a subfolder: img/logo.png written inside css/ would look for css/img/logo.png.
  • Mixing case: file Logo.PNG, path logo.png. It works on Windows; it fails on the server.
  • Spaces and accents in names: rename the file before linking to it (Gallery Café.jpg → gallery-cafe.jpg).
  • Using a leading / by accident: /menu.html is not the same as menu.html. When you double-click, the first one doesn't work.
  • Tip: VS Code autocompletes paths. When you type src=" or href=", a list of the available files and folders appears; use it to avoid typos.

Exercises

Exercise 1. Safe names. Suggest a correct name for each file:

  1. Storefront Photo.JPG
  2. Café_Autumn_Menu.html
  3. IMG_0042.png (it's a photo of the lemon sponge cake)
  4. Intro Video (final).mp4

Exercise 2. Write the paths. Using the project structure from this lesson, write the relative path you need:

  1. In index.html, to link to contact.html.
  2. In gallery.html, to display img/storefront.jpg.
  3. In gallery.html, to refer to media/intro.mp4.
  4. In a css/styles.css file, to refer to img/logo.png.
  5. In a news/2026-opening.html file (a future news subfolder), to go back to index.html.

Exercise 3. Find the error. Inside the-blue-cup/menu.html there are these lines, and none of them works when the file is opened by double-clicking. Explain why and correct them.

<img src="C:\Users\anna\Documents\the-blue-cup\img\logo.png" alt="Logo">
<img src="../img/logo.png" alt="Logo">
<a href="/index.html">Home</a>
<a href="Bookings.html">Bookings</a>

Solutions

Solution 1.

  1. storefront-photo.jpg (lower case, hyphen, extension in lower case).
  2. cafe-autumn-menu.html (no accent, hyphens instead of underscores, lower case). autumn-menu.html would also be fine.
  3. lemon-cake.png (descriptive).
  4. intro-video.mp4 (no spaces or brackets).

Solution 2.

  1. contact.html (or ./contact.html).
  2. img/storefront.jpg.
  3. media/intro.mp4.
  4. ../img/logo.png (from css/ you need to go up one level).
  5. ../index.html.

Solution 3.

  1. A hard drive path with backslashes: it would only work on Anna's computer, and never once published. Correct: img/logo.png.
  2. ../ goes up one level from the-blue-cup/, leaving the project; there is no img folder there. Correct: img/logo.png.
  3. /index.html is root-relative: with file:/// it points to the root of the drive. Correct: index.html.
  4. The file is called bookings.html, in lower case. It may work on Windows, but it will fail on a Linux server. Correct: bookings.html.
<img src="img/logo.png" alt="Logo">
<img src="img/logo.png" alt="Logo">
<a href="index.html">Home</a>
<a href="bookings.html">Bookings</a>

Conclusion

Your project now has a professional structure: the six pages (index.html, menu.html, bookings.html, gallery.html, news.html and contact.html) in the root and the css/, img/ and media/ folders for resources, all with lower-case names, hyphens and no spaces or accents. You know that index.html is the page the server delivers by default, that relative paths (menu.html, img/logo.png, ../index.html) start from the current file and keep the project portable, and that absolute paths (full URLs or paths starting with /) have their place for external sites or servers configured from the root. This brings the introductory module to a close: you know what HTML is, your environment is ready, you have mastered the structure of a document and its syntax, and you have created the foundations of The Blue Cup. In the next module, Text Formatting in HTML, you will start shaping the content of the pages with headings, paragraphs, emphasis, lists and quotations, beginning with the lesson Headings and Paragraphs.

HTML Course

Module 1: Introduction to HTML

Module 2: Text Formatting in HTML

Module 3: Links and Media in HTML

Module 4: Tables in HTML

Module 5: Forms in HTML

Module 6: HTML5 Semantic Elements

Module 7: Advanced HTML Techniques

Module 8: Integrating HTML and CSS

Module 9: Responsive Web Design

Module 10: Best Practices and Accessibility

Module 11: Project: Building a Complete Website

© Copyright 2026. All rights reserved