Publish on GitHub Pages

The garden’s site works on your computer, and the project later in this course finishes it. It already has an FAQ, an hours popover, motion that respects your visitors’ settings, a dark mode, and a head that Lighthouse has checked. However, only you can see it. Rosa wants an address she can print on the noticeboard flyer and share with new volunteers.

In this lesson, you’ll put the site online with GitHub Pages, a free service that serves a folder of HTML, CSS, and images at a public address. You’ll do it in the browser, without installing anything, and then check every page of the live site. Publishing is optional and needs a free GitHub account, so if you’d rather not create one, read along and use the no-account alternative near the end.

Put the Garden’s Files in a Repository

GitHub Pages publishes a website from a repository: a folder of files stored on GitHub, with a history of every change. The garden’s files need one of their own. If you don’t have an account yet, sign up at github.com, then follow these steps in another tab:

  1. Click the + in the upper-right corner of any GitHub page, then click New repository.
  2. Type garden as the repository name. Keep it lowercase, because it becomes part of the site’s address.
  3. Choose Public as the visibility.
  4. Turn Add README on. This gives the repository its first file, so the page you land on offers the Add file menu.
  5. Click Create repository.

The repository’s main page shows its branch name in a menu above the list of files. A branch is a line of the repository’s history, and yours has one so far, usually called main. If the menu shows another name, such as master, use that name wherever this lesson says main, or rename it: click Settings, then the pencil button next to the default branch’s name, and type main.

Watch out: a private repository doesn’t keep the site private. On a free account, Pages doesn’t publish a private repository at all, and on a paid plan, the site is still public. Treat everything you upload as public.

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

Become a Member to join the conversation.