This is one foundational lesson in the twelve-lesson course.
The question to explore
Give your story a home
How does a program find the right file?
A path is a file’s address. Change the folder or the name and the address changes, but the words inside stay the same. Tell an AI coding helper the exact address of the draft you mean. An AI coding helper needs the address of the file you mean. Change the folder here and watch the path change while the text stays the same. Use that distinction when telling a helper which draft to read or edit.
Local teaching illustration / No AI model call / About 8 minutes / No account needed
Try the experiment
First step: Read the displayed path for story.txt in the drafts folder.
This is a virtual folder. Downloading creates workshop-story.txt through your browser; it does not create folders on your device.
/workshop/drafts/story.txt
workshop/ → drafts/story.txt
- drafts/ active
- story.txt
- research/ empty
- characters/ empty
Mira carries a message to the lighthouse.
Change a control to explore the example when JavaScript is enabled.
- Read the displayed path for story.txt in the drafts folder.
- Use the Folder menu to choose Research or Characters. Change the virtual file name and watch the path update.
- Edit the line of text. Choose Download a text copy if you want to keep it, then compare the virtual address with the downloaded file name.
The idea
The words in a note are what it says. The folder and file name are where it lives. Think of a note you want to keep: a recipe, a reminder or the start of a story. The words are its contents. The folder and file name tell a program where to find it.
A file holds your words. A folder groups files. A path tells a program which file you mean. Moving a file can change its address without changing its words. A file holds information. A folder (a directory) groups files. A path names the route to a file as segments separated by slashes, much like directions through a building. Changing the folder or file name changes that route. A relative path such as workshop/drafts/story.txt is read from the program’s current working directory; an absolute path such as /home/reader/workshop/drafts/story.txt starts at the root. The segment .. means the parent folder, so a joined path can climb out of the folder you meant unless the program normalizes it and checks where it lands.
This activity shows a virtual location; it does not move files on your computer. The download saves workshop-story.txt with the virtual path written inside it. This experiment displays a virtual address under /workshop/; it does not rearrange files on your computer. It accepts only the three listed folders, replaces unusual characters in the file name with underscores, and falls back to story.txt for an unsafe or blank name, so the address stays inside the chosen folder. The download button saves a text copy named workshop-story.txt through your browser, with the virtual path included inside.
Worked example: run it yourself
A few lines of Node.js build file addresses from folder and file names and print them. The last step asks for a file that does not exist, and the program says so instead of guessing. path.posix.join builds a path from segments and normalizes it; the posix version gives the same output on Windows, macOS and Linux. resolve turns a relative path into an absolute one. Joining ../../notes.txt onto workshop/drafts climbs two levels and lands outside both folders, which is why the experiment cleans file names. readFile on a missing path rejects with the error code ENOENT (no such file or directory).
Save it as paths.mjs and run node paths.mjs in a terminal (Node.js 18 or later). Download paths.mjs
import path from 'node:path';
import { readFile } from 'node:fs/promises';
const where = path.posix.join('workshop', 'drafts', 'story.txt');
console.log(where);
console.log(path.posix.join('workshop', 'research', 'story.txt'));
console.log(path.posix.dirname(where), '|', path.posix.basename(where));
console.log(path.posix.resolve('/home/reader', where));
console.log(path.posix.join('workshop/drafts', '../../notes.txt'));
try {
await readFile('workshop/drafts/story.txt', 'utf8');
} catch (error) {
console.log(error.code);
}
Output, as printed by Node.js 25.3.0 on 3 December 2026:
workshop/drafts/story.txt
workshop/research/story.txt
workshop/drafts | story.txt
/home/reader/workshop/drafts/story.txt
notes.txt
ENOENTTry it
Before you run it, predict what path.posix.join('workshop', 'drafts', '..', 'characters', 'mira.txt') prints. Add it to paths.mjs inside console.log() and check.
Check your answer
workshop/characters/mira.txt. The .. segment cancels drafts, so the path goes up one folder and then into characters.
Take this with you
What changed?
Content and location are different. The same story can have a new address.
Try explaining it.
If a program still asks for the old path after a move, should it silently pretend the file is there?
Open a possible explanation
No. It needs an updated reference or an explicit missing-file result. Guessing a different file could supply the wrong story.
Choose a next step
Continue the course in order, or open the course map.