A site can look right in your local preview and still have paths that break once it’s published. This lesson follows one missing photo from the preview to GitHub Pages, finds the cause in DevTools’ Network panel, and fixes it.
Key Points
- A local preview doesn’t prove your paths. If you published the garden, every page may well look right online, and you don’t need to upload anything here: the video shows a demonstration copy of the garden. On it, the seed swap page’s photo tag asks for
../images/Seed-swap.jpg, with a capital S, while the file isimages/seed-swap.jpg. In the editor’s live preview on macOS or Windows, the photo shows. At the GitHub Pages address, the page loads with its styles, but the photo is replaced by a broken image icon and its alt text. - HTML doesn’t report errors, so the page alone won’t tell you why. Open DevTools, choose the Network panel, and reload, because the panel records only while it’s open. Each row is one file the page asked for, with the server’s answer:
200means found,404means not found. The page andstyle.cssshow200, andSeed-swap.jpgshows404. - Why: the browser sends the exact name, and each server asks its own computer’s file system for that file. GitHub’s file system, like Linux’s, matches names letter for letter, so
Seed-swap.jpgis a different name, and no file has it. On macOS and Windows, the file system ignores letter case by default, so the preview found the lowercase file anyway. On Linux, the preview would fail too. - The fix: the garden keeps its file names lowercase, so fix the path rather than renaming the file. Change the
srcto match the file’s name, then upload the fixed page,seed-swap.html: in the repository, open theeventsfolder, use Add file, then Upload files, and click Commit changes. A file with the same name replaces the old one. Wait for the deployment to finish, which can take several minutes. Then hard reload, with Ctrl+Shift+R, or Cmd+Shift+R on a Mac, so the browser asks the server again. The photo’s row shows200, and the photo is back. - Paths that start with a slash start at the root. In your preview, the
gardenfolder is the root, so they work. Online, the root is the domain, outside yourgardenfolder, so<link rel="stylesheet" href="/style.css">ingarden/index.htmlasks for the domain’s ownstyle.cssand gets a404. The garden’s paths are relative to the page (style.cssfromgarden/index.html,../style.cssfromevents/seed-swap.html), so they keep working. - Watch out: Pages runs your files through a tool called Jekyll, which skips files and folders whose names start with an underscore (
_). An empty file named.nojekyllat the top of the repository turns Jekyll off. - The rule: keep file names lowercase, match them letter for letter, and check every published page in the Network panel for 404 errors.
Final Code
The seed swap page’s photo, in events/seed-swap.html, with its src matching the file’s name letter for letter: