Basics

What is a file path — and why it works on your computer but not on the server

Illustration: a thread runs through nested drawers to a single card

A classic. On your laptop the site works perfectly. You deploy it to a server — and half the images are gone. Same code. Same files. Everything's in place.

And the problem is one letter. The code says Logo.png, but the file is named logo.png. Your Mac can't tell the difference. A Linux server can. Let's see why — and along the way, understand how file paths work at all.

What a file path is, in plain words

A path is a file's address. Like a postal one: country, city, street, building, apartment. Only instead of streets — folders nested inside each other.

/Users/anya/projects/shop/images/logo.png

Read it left to right: the Users folder contains anya, which contains projects, then shop, then images. And in there — the file logo.png. Each / means "step inside".

Whenever code says "read a file" or "show an image", it names an address like this. Get it wrong by a single character and the file is "not found", even though it's sitting exactly where you think.

Absolute and relative paths

Addresses come in two kinds. The difference is like "7 Main Street, London" versus "the next door over".

  • An absolute path starts from the very root of the disk. On Mac and Linux it starts with /; on Windows with a drive letter, C:\. It's the same no matter where you look from.
  • A relative path is counted from where you are right now. It's shorter, but its meaning changes with the starting point.

Relative paths have two special markers:

  • ./ — "this folder". ./style.css means "the file style.css right here".
  • ../ — "one level up". ../images/logo.png means "leave the current folder, go into images".

Say you're standing in the shop/pages folder. Then ../images/logo.png leads to shop/images/logo.png. Stand in a different folder and the same path leads somewhere else. Or nowhere.

The main trap: "here" is where?

This is where beginners stumble most. "Where I am now" isn't always the place where the code file lives.

  • In the browser, a relative path is counted from the page's address. An image images/cat.png on the page /blog/post/ is looked up at /blog/post/images/cat.png. A path starting with /, /images/cat.png, is counted from the site's root. This is a common reason images don't load.
  • In Node.js and Python, a path like ./data.json is counted from the folder the program was started from. Run the script from the project folder — it works. Run it from a neighboring one — "file not found". That's the folder the terminal shows before the cursor.

Why it works on a Mac but not on the server

Here's the answer to the opening mystery. Three differences that surface when code moves:

  • Letter case. On Mac and Windows, by default, Logo.png and logo.png are the same file. On Linux they're two different files. And servers are almost always Linux.
  • Slashes. Windows writes paths with a backslash \; Mac and Linux with a forward slash /. A path glued together by hand on Windows can break on the server.
  • An absolute path from your computer. /Users/anya/... exists only on Anya's laptop. There's no such folder on the server. AI sometimes pastes paths like that into code — check for them.

One simple rule saves you from all three. Name files in lowercase Latin letters, with no spaces. And write paths exactly as the file is named — letter for letter.

How to find the right path fast

Don't guess — ask the computer.

  • In VS Code or Cursor, right-click a file → Copy Relative Path. You get the exact path from the project root.
  • In the terminal, pwd shows which folder you're in right now. And ls shows what's in it.
  • If the file is lost somewhere in a big project, the tricks from how to find code in a big project will help.

What does "/" at the start of a path mean?

In the file system — "start from the root of the disk". On a website — "start from the root of the domain", i.e. from kodiq.ai. Either way it's an absolute path.

Can I use spaces and non-Latin letters in file names?

Technically yes, but it's a common source of errors. Spaces in addresses turn into %20, and non-Latin letters into long codes. Latin letters and hyphens are safer: my-photo.png.

What does "ENOENT" in an error mean?

It's the error code for "no such file or directory". It almost always means one thing: the path is wrong. Check the letter case, typos, and where the program was started from.

Become an AI architect — don’t just read about AI

The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.

About the Academy
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →