Host a Website on Github

Tanuka Das
2 min readJan 12, 2020

--

Hosting a website on GitHub is free and very easy.

Start by creating a new GitHub repository and create a file called index.html. This is the default page that will load when someone goes to the website. Add the website content in the index.html file.

Next, commit the changes with a message and push it to the master branch.

Github works by being back up by git, which is a version control system. It lets you take snapshots of your files. This way if you mess up something in the file, you can easily rollback those to the previous commit. You can also push the code in a new branch and merge that to the master branch. For the purpose of this blog post, I pushed it directly to the master branch.

To set up GitHub pages, create a new branch called gh-pages

Next, set the gh-pages branch as the default branch. For that, go to your repository project settings, select the third option “Branches” and change the “Default branch” dropdown menu from master to gh-pages; hit update to set that as the default branch. Now if you go to the project repository, you’ll gh-pages as your default branch.

Now, just by doing that we’ve turned a simple GitHub repository to a website that is public for everybody to see. The URL is:

If you enter that you’ll land on the webpage that looks exactly the same as the locally hosted webpage.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Tanuka Das
Tanuka Das

Written by Tanuka Das

Software Developer, technical writer, bookworm, constant learner.

No responses yet

Write a response