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
- The project folder structure
- Conventions for naming files and folders
index.html: the default page- What a path is
- Relative paths: same folder, subfolders and
../ - Absolute paths: full URLs and root-relative paths
- Comparison and when to use each
- 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.mp3The 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.htmlmkdir css img media: creates the three subfolders in one go.touch …: creates empty files (on macOS and Linux; in Windows PowerShell useNew-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.pngandimg/logo.pngwork 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.htmlwouldn't work on many servers). - Live Server also follows this convention: if you visit
http://127.0.0.1:5500/, it will showindex.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>creates a link; itshrefattribute contains the path to the destination.<img>displays an image; itssrcattribute 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 /:
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 fromcss/tothe-blue-cup/, intoimg/and takeslogo.png.../index.html: goes up tothe-blue-cup/and takesindex.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 inimg/.
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/logo.pngmeans "from the root of the site, go intoimgand takelogo.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.pngorfile:///C:/…): they only work on your computer. When you publish, they all break. - Forgetting
../from a file in a subfolder:img/logo.pngwritten insidecss/would look forcss/img/logo.png. - Mixing case: file
Logo.PNG, pathlogo.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.htmlis not the same asmenu.html. When you double-click, the first one doesn't work. - Tip: VS Code autocompletes paths. When you type
src="orhref=", 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:
Storefront Photo.JPGCafé_Autumn_Menu.htmlIMG_0042.png(it's a photo of the lemon sponge cake)Intro Video (final).mp4
Exercise 2. Write the paths. Using the project structure from this lesson, write the relative path you need:
- In
index.html, to link tocontact.html. - In
gallery.html, to displayimg/storefront.jpg. - In
gallery.html, to refer tomedia/intro.mp4. - In a
css/styles.cssfile, to refer toimg/logo.png. - In a
news/2026-opening.htmlfile (a future news subfolder), to go back toindex.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.
storefront-photo.jpg(lower case, hyphen, extension in lower case).cafe-autumn-menu.html(no accent, hyphens instead of underscores, lower case).autumn-menu.htmlwould also be fine.lemon-cake.png(descriptive).intro-video.mp4(no spaces or brackets).
Solution 2.
contact.html(or./contact.html).img/storefront.jpg.media/intro.mp4.../img/logo.png(fromcss/you need to go up one level).../index.html.
Solution 3.
- A hard drive path with backslashes: it would only work on Anna's computer, and never once published. Correct:
img/logo.png. ../goes up one level fromthe-blue-cup/, leaving the project; there is noimgfolder there. Correct:img/logo.png./index.htmlis root-relative: withfile:///it points to the root of the drive. Correct:index.html.- 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
- What Is HTML?
- Setting Up Your Work Environment
- Basic Structure of an HTML Document
- Tags, Elements and Attributes
- Creating Your First HTML Page
- File Organisation and Paths
Module 2: Text Formatting in HTML
- Headings and Paragraphs
- Text Formatting Tags
- Lists: Ordered, Unordered and Description Lists
- Block Quotes and Preformatted Text
- Block and Inline Elements: div and span
Module 3: Links and Media in HTML
- Creating Hyperlinks
- Special Links: Anchors, Email, Phone and Downloads
- Adding Images
- Embedding Videos
- Using the Audio Element
Module 4: Tables in HTML
- Basic Table Structure
- Table Head, Body and Foot
- Merging Cells: colspan and rowspan
- Accessible Tables: caption, scope and headers
- Styling Tables
Module 5: Forms in HTML
- Creating a Basic Form
- Form Elements: input, textarea and select
- HTML5 Input Types
- Labels and Grouping: label, fieldset, legend and datalist
- Form Attributes and Validation
- Submitting Forms
Module 6: HTML5 Semantic Elements
- Introduction to Semantic HTML
- header, nav and footer
- article, section and aside
- main and figure
- Other Semantic Elements: time, address, details and dialog
Module 7: Advanced HTML Techniques
- HTML Entities
- Using iframes
- Data Attributes
- Metadata: meta, SEO and Open Graph
- Microdata and Structured Data
- Graphics in HTML: SVG and canvas
Module 8: Integrating HTML and CSS
- Linking CSS to HTML
- Inline, Internal and External CSS
- Basic CSS Selectors
- The Box Model
- Styling HTML Elements
- Introduction to Layout with Flexbox and Grid
Module 9: Responsive Web Design
Module 10: Best Practices and Accessibility
- HTML Best Practices
- Validating HTML Code
- Web Accessibility Basics
- Using ARIA Roles and Attributes
- Accessibility Testing
- Performance and Resource Loading
