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.

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
/workshop/drafts/story.txt

Mira carries a message to the lighthouse.

Change a control to explore the example when JavaScript is enabled.

  1. Read the displayed path for story.txt in the drafts folder.
  2. Use the Folder menu to choose Research or Characters. Change the virtual file name and watch the path update.
  3. 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.

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.

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.

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.

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
ENOENT

Try 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.