How to publish your web pages with GitHub

When you have written some code, it is on your computer so you can only see the web page from your computer. Other people can't see it because they don't have access to your computer. But we can do a few steps and put our code online and give it an URL so everybody with a link can see your web pages.

Sign up for GitHub

Imagine your code is some kind of paper document, GitHub is like a storage place. We put our code in Github and we will be given a key to the storage, which is the URL, anyone with the URL will be able to access the web page.

Use this link to sign up for GitHub.

Create a repository

Then on the top right of the dashboard, click on the + button and select the first option "New repository".

In "Repository name"(see 1 in the picture), put in a name that describes what your web page is. You can't have space in the name so I usually connect the words with - or _. And we like to keep our repository public (2) in most cases if you don't have any secrets in it.

Leave all the options as in the picture and scroll down to the bottom and click the green button "Create repository". By doing this, quite literally, we are creating a repository - a storage space for our code.

Uploading your code to the repository

After creating the repository, you will be redirected to the repository page which looks like this.

Then click on "uploading an existing file" and add all the files (in my case, it's just a index.html but you might have a css file you want to upload as well) in your project folder here. After adding a file, you should see it appear on the page. Finally, click on the green button "Commit changes" and your files are uploaded to the repository.

Publish your web page

Now, how do we get the URL for people to view your website? It's pretty simple too. Go to "Settings" tab(1) on your repository, and then "Pages"(2) on the left-hand side. On the main section, under "Branch", select "main"(3) and then click on "Save".

Wait for a few minutes and refresh the page, you will see a link and that's your link, click on "Visit site" and you will see your very own web page online now.

That's it, you made it again. Coding is simple. Now go build some cool websites and publish them online =)