Lesson 2 of 51 · Module 1, lesson 2 of 6 · 5 min

Files, folders and file extensions

Make your computer show file extensions and create a folder for your website, on Windows or macOS.

What you'll learn

  • What files, folders and file extensions are
  • How to make your computer show file extensions (Windows and macOS)
  • How to create a folder for your website, with names that will not cause problems

Why this matters

A website is a set of files inside folders. The browser finds your pages and pictures by their exact names and places. The most common problem for new web developers is a file with the wrong name — very often because the computer was hiding part of the name. Ten minutes here will save you hours later.

Files, folders and paths

  • A file is one saved item: a photo, a document, a web page.
  • A folder (also called a directory) is a container for files and for other folders.
  • A path is the address of a file: the folders you open, one inside the other, to reach it. For example: Documents › my-website › index.html.

File extensions

The file extension is the part of a file name after the last dot. It tells the computer what kind of file it is, and which program should open it.

File nameExtensionKind of file
index.html.htmlWeb page
photo.jpg.jpgPhoto
notes.txt.txtPlain text
report.docx.docxWord document

A web page must end in .html. A file called index.html opens in a browser as a web page. A file called index.html.txt opens as plain text, even though the first part of the name looks right.

Here is the problem: Windows and macOS hide extensions when they are first set up. You may see index.html when the real name is index.html.txt. So your first job is to make your computer show the full name of every file.

Show file extensions on Windows

Windows 11

  1. Open File Explorer: click the folder icon on the taskbar, or press Windows key + E.
  2. At the top, click View.
  3. Point to Show.
  4. Click File name extensions, so that it has a tick.

Windows 10: open File Explorer, click the View tab at the top, and tick File name extensions.

Windows 11 File Explorer. Step 1: the View button at the top is highlighted. Step 2: in the menu that opens, Show is highlighted. Step 3: in the next menu, File name extensions has a tick. The files in the folder now show their full names, notes.txt and photo.jpg.

Show file extensions on macOS

  1. Click an empty part of the desktop, so that Finder is the active program. Its name appears in the top-left corner of the screen, next to the Apple logo.
  2. In the menu bar at the top, click Finder, then Settings… (on older versions of macOS: Preferences…).
  3. Click Advanced.
  4. Tick Show all filename extensions.

macOS. Step 1: Finder is selected in the menu bar. Step 2: Settings is highlighted in the Finder menu. Step 3: the Finder Settings window is open on the Advanced tab, and "Show all filename extensions" is ticked.

Create a folder for your website

Keep all the files for one website together, in one folder. In this course that folder is called my-website, and it lives in your Documents folder.

Windows

  1. In File Explorer, click Documents on the left.
  2. Click New (Windows 11) or New folder on the Home tab (Windows 10). On Windows 11, choose Folder.
  3. Type my-website and press Enter.

macOS

  1. In Finder, click Documents in the sidebar on the left.
  2. Click File › New Folder, or press Command + Shift + N.
  3. Type my-website and press Return.

The Documents folder on Windows and on macOS, each containing a new folder called my-website. Below: good names such as my-website, index.html and contact-us.html, and names that cause trouble such as "My Website" (a capital letter and a space), Index.HTML (capital letters) and "contact us.html" (a space).

Naming rules that save you trouble

Use these rules for every file and folder in a website:

  • Lowercase letters only. Write about.html, not About.html. Many web servers treat About.html and about.html as two different files, so a link that works on your computer can break online.
  • No spaces. Use a hyphen instead: my-website, contact-us.html. In a web address a space becomes %20, and that causes many broken links.
  • Only letters, numbers and hyphens — plus the dot before the extension.

What you'll see

A new, empty folder called my-website inside Documents. With extensions turned on, files you already had now show their endings, such as .jpg, .pdf or .docx.

Try it yourself

Open your Documents or Downloads folder and look at the files. Can you see their extensions now? Find three different extensions and say what kind of file each one is.

Common mistakes

  • Skipping the "show extensions" step. Later, a file that you think is index.html is really index.html.txt, and it opens as text. How to spot it: the browser shows your code instead of a page. Fix: turn on extensions, then rename the file so that it ends in .html only.
  • Spaces or capital letters in names, such as My Website/Index.HTML. It may work on your computer and then break on a web server. Fix: rename everything to lowercase with hyphens now, while the project is small.
  • Saving files in different places. One file on the Desktop, another in Downloads. Your pages will not find each other. Fix: keep everything inside my-website.

Check yourself

  1. What is the extension of soup-recipe.html?
  2. Why is My Page.html a poor name for a file in a website?
  3. Where will you keep all the files for your first website?

Answers

  1. .html
  2. It has a capital letter and a space. Use my-page.html.
  3. In the my-website folder, inside Documents.

Next: you have a folder. Now you need a program to write code in — a code editor.

Chat with us on WhatsApp