Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Publish to GitHub Pages

In this video, you put a stand-in copy of Alex’s packing list online with GitHub Pages, checked the live site in DevTools, and published a fix. Publishing is optional. To do it, you need a free GitHub account with a verified email address, and the repository must be public.

Key Points

  • GitHub Pages serves your folder’s files the way Live Preview does, but on the internet, at an address anyone can open. Unlike Live Preview, it changes only when you upload.
  • Create a repository: on GitHub, create a new repository named packing-list, like your folder. Make it Public and turn on Add README, so the repository doesn’t start empty.
  • Upload the files, not the folder: open Add file and choose Upload files. From your packing-list folder, select everything inside and drag those files onto the page. When an address ends at a folder, the server sends that folder’s index.html, so index.html must sit at the top of the repository. Then commit the upload, which saves it in the repository.
  • Turn on Pages: in the repository’s Settings tab, open Pages in the sidebar. Under Source, choose Deploy from a branch. Pick the main branch, where your upload went, and the / (root) folder, the top of the repository. Then click Save.
  • Wait for the green check: GitHub publishes your files as they are. The Actions tab shows a run called pages build and deployment, with a yellow dot while it works. It often takes about a minute, sometimes several. Then the dot turns into a green check. A failed deploy shows a red cross there instead.
  • The address: back in Settings ▸ Pages, you’ll find your site’s address and a Visit site button. The address is your username, then github.io, then the repository’s name, such as https://alex.github.io/packing-list/.
  • Check the live site: with DevTools open, the Console should show no errors. To see every file arrive, open the Network panel and reload the page. Each file gets a row (the page itself, then the stylesheet and all the modules), and every file loads: 200, or 304 for the page itself, which means the browser’s copy is still current.
  • A 404 names a file the server couldn’t find. Fix its path or the case of its name, upload it again, and hard-reload after the next green check (see Watch out below).
  • Publish a change: fix the file and check it in Live Preview, then upload it the same way. A file with the same name replaces the old one. Committing starts a new run in the Actions tab. Wait for its green check.
  • Watch out: a plain reload can still show the old page for up to ten minutes, because Pages tells browsers they may reuse its files for that long. After a green check, an old page is most likely a cached copy, not a failed deploy. Hard-reload with Ctrl+Shift+R, or Cmd+Shift+R on a Mac, to fetch every file again.
  • Still the old page? If a hard reload still shows the old page, check that the uploaded file in the repository has your fix, and that the address you opened is your Pages address.

The Steps

Once:

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

00:00 Your packing-list folder is ready for a static host. Its paths are relative, its file names match, its storage key is its own, and nothing in it is secret.

00:09 So how do you get it online?

00:12 You’ll use GitHub Pages to publish it. Pages serves your folder’s files the way Live Preview does, but on the internet, at an address anyone can open. Unlike Live Preview, it changes only when you upload.

00:25 You need a free GitHub account with a verified email address, and the repository must be public. Publishing is optional, so watch now and publish later.

00:37 On GitHub, create a new repository. Name it packing-list, like your folder, and make it public. Turn on Add README, so the repository doesn’t start empty. The account in this video is called alex.

00:51 Open the Add file menu and choose Upload files. From your packing-list folder, select everything inside and drag those files onto the page. Drag the files, not the folder.

01:03 When an address ends at a folder, the server sends that folder’s index.html. So index.html must sit at the top of the repository. Then commit the upload, which saves it in the repository.

01:16 Your six files appear beside the README.

01:21 Committing saves the files, but nothing serves them yet. Open the repository’s Settings tab, then Pages in the sidebar. Under Source, choose Deploy from a branch.

01:33 Pick the main branch, where your upload went, and the root folder, the top of the repository. Then click Save.

01:41 GitHub now publishes your files as they are. Open the Actions tab to watch. A run called pages build and deployment shows a yellow dot while it works. It often takes about a minute, sometimes several.

01:54 Then the dot turns into a green check. Back in Settings, Pages shows a Visit site button and your site’s address: your username, then github.io, then the repository’s name.

02:08 Click Visit site, and open DevTools. The page shows the video’s copy of Alex’s packing list and its Beach Week trip. The Console shows no errors.

02:20 To see every file arrive, open the Network panel and reload the page. Each file gets a row. There’s the page itself, then the stylesheet and all four modules.

02:31 Every file loads: 200, or 304 for the page itself, which means the browser’s copy is still current. A 404 in that column names a file the server couldn’t find.

02:43 Fix its path or the case of its name, and upload it again. After the next green check, hard-reload. You’ll meet that in a moment.

02:53 Say Alex spots a typo in this copy. Every progress line says pakced, with the K and C swapped. Fix it in render.js and check it in Live Preview. Then upload render.js the same way.

03:07 It replaces the old one. Committing starts a new run in the Actions tab. Wait for its green check. A failed deploy shows a red cross there instead. Watch out: a plain reload can still show the old page for up to ten minutes.

03:23 Pages tells browsers they may reuse its files for that long. After a green check, an old page is most likely a cached copy, not a failed deploy. So hard-reload with Ctrl+Shift+R, or Cmd+Shift+R on a Mac.

03:38 A hard reload fetches every file again. The progress lines now say packed.

03:45 As a rule, set it up once: upload the folder’s files with index.html at the top, and deploy from the main branch. For every change after that, upload the file.

03:57 Each time, the first publish too, wait for the green check. With DevTools open, hard-reload, then check the Console and the Network panel. Alex’s packing list is online now, so they can open it on their phone while they pack.

04:11 Next, in Plan and Build Your Own Tool, you’ll plan and build a tool of your own the way you built Alex’s, one feature at a time.

Become a Member to join the conversation.