Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Basic steps for hosting on Github

Hey there, apparently people are still using this Gist from 2013! It's out of date! Consult the Github docs.

Steps for Hosting a Website on GitHub

  1. Create a GitHub account on github.com.
  2. Download either GitHub for Mac or GitHub for Windows, depending on your operating system. Open the app and log in using the account you just created.
  3. (On Mac): After you login, click advanced and make sure that your name and email are correct. Then, click "Install Command Line Tools", just in case you want to start using the command line later in life.
  4. Create a new repository in your GitHub application. Name it your-username.github.io. The name is very important. Note the folder that GitHub is saving the repository to. Make sure the "Push to GitHub?" box is checked.
  5. Move your website's files into the folder that GitHub just created when you made the repository. IMPORTANT: Your homepage HTML file must be called "index.html", and it must exist in the top-level directory.
  6. Back in the GitHub application, you should see your files in the left column. Make sure they are all checked. If so, enter a message in the text box called "commit summary", something like "initial commit." Then, click the commit button.
  7. Click the "Publish repo" button in the top right corner.
  8. Give it about 10 minutes, then check your-username.github.io. Your website should be there!

Using a custom domain name

You can just leave your website at that address (it'll give you some serious street cred in the developer world), but if you have a custom domain you would like to use, it is very simple to make GitHub redirect your page.

  1. Log in to your domain registrar and find where to change your host records. If you don't know, you can usually Google "(domain registrar) change host records", and your registrar will have an explainer telling you how to do it.
  2. Change your domain's A Record to 204.232.175.78. This is GitHub's IP address, which allows GitHub to resolve your URL and serve the correct files.
  3. In your website's directory folder on your computer, create a file called "CNAME". On the first line, type your domain name. Save the file.
  4. In your GitHub application, you should see the file in the left column. Make sure it is checked and enter your commit message. Have it say something like "Adding CNAME file."
  5. Click "Sync branches."

It can take as long as 48 hours for your domain to resolve to your GitHub page. However, it is usually pretty quick, so check back in an hour or so.

@JubrilJuma

This comment has been minimized.

Copy link

JubrilJuma commented Nov 26, 2017

Thank you!

@cipriandraghici93

This comment has been minimized.

Copy link

cipriandraghici93 commented Jan 14, 2018

Great, thanks !

@ttngocthao

This comment has been minimized.

Copy link

ttngocthao commented Feb 14, 2018

Thanks, that is very helpful!

@mdfaizulislam

This comment has been minimized.

Copy link

mdfaizulislam commented Feb 19, 2018

Great!
Thanks a lot.

@tobioye88

This comment has been minimized.

Copy link

tobioye88 commented Feb 22, 2018

I should try this some time

@ghost

This comment has been minimized.

Copy link

ghost commented Feb 23, 2018

this helps.

@nchos88

This comment has been minimized.

Copy link

nchos88 commented Feb 26, 2018

Nice post! thanks a lot!

@AaronDrobek

This comment has been minimized.

Copy link

AaronDrobek commented Mar 9, 2018

you have to use your username, or you can name the file anything? This isn't working for me....

@SuharshTyagii

This comment has been minimized.

Copy link

SuharshTyagii commented Mar 31, 2018

TYTYTYTY

@mapuchila

This comment has been minimized.

Copy link

mapuchila commented Apr 5, 2018

Many thanks!

@gamesforbryan

This comment has been minimized.

Copy link

gamesforbryan commented Apr 21, 2018

You now need to go to Settings -> GitHub Pages -> and select a source for the web site.

@EOussama

This comment has been minimized.

Copy link

EOussama commented Apr 29, 2018

This was a great help, thank you.

@balaji961

This comment has been minimized.

Copy link

balaji961 commented May 2, 2018

Great piece of work

@Coder-ACJHP

This comment has been minimized.

Copy link

Coder-ACJHP commented May 5, 2018

Thank you so much

@frankovo

This comment has been minimized.

Copy link

frankovo commented May 12, 2018

Awesome work. Big grazie.

@bestorw01

This comment has been minimized.

Copy link

bestorw01 commented May 16, 2018

Thank you so Much

@ogekingsley

This comment has been minimized.

Copy link

ogekingsley commented May 19, 2018

Thank you very much...

@foresteps

This comment has been minimized.

Copy link

foresteps commented May 25, 2018

Thank you very much...this is just the info I need.

@aakshaymore

This comment has been minimized.

Copy link

aakshaymore commented Jun 5, 2018

I had to wait for more than 10 minutes to see the changes reflect. Thank a lot .

@DwGonzalez

This comment has been minimized.

Copy link

DwGonzalez commented Jun 6, 2018

Thank you very much for this post, very helpful information.

@Jenn122783

This comment has been minimized.

Copy link

Jenn122783 commented Jun 9, 2018

Super helpful! Appreciated!

@1Dineshkumar

This comment has been minimized.

Copy link

1Dineshkumar commented Jun 16, 2018

But my pc is 32bit.......??

@sislinigeria

This comment has been minimized.

Copy link

sislinigeria commented Jun 25, 2018

I love this. Thank you.

@solomonaleka

This comment has been minimized.

Copy link

solomonaleka commented Jun 26, 2018

That was helpful

@Mercien

This comment has been minimized.

Copy link

Mercien commented Jun 27, 2018

Cool, pretty helpful

@antoncoding

This comment has been minimized.

Copy link

antoncoding commented Jul 1, 2018

thanks for the tips!

@nimeish811

This comment has been minimized.

Copy link

nimeish811 commented Jul 13, 2018

thanks for tips

@leenMalka

This comment has been minimized.

Copy link

leenMalka commented Jul 30, 2018

you are life saver 👍

@cdoffx

This comment has been minimized.

Copy link

cdoffx commented Jul 31, 2018

How about hosting a nodejs page?

@faizaldong

This comment has been minimized.

Copy link

faizaldong commented Aug 10, 2018

@cdoffx you cant deploy nodejs via hosting. You need vps. Once you have vps then you need to setup your nodeja environment on your server

@pemeraldy

This comment has been minimized.

Copy link

pemeraldy commented Aug 27, 2018

Nice!!! n striaght forward... thanks man

@praven15

This comment has been minimized.

Copy link

praven15 commented Oct 2, 2018

gg

@Oluwa-nifemi

This comment has been minimized.

Copy link

Oluwa-nifemi commented Dec 4, 2018

Good day
You can now host from Settings (For a repo) ->Github pages

@gsaathof

This comment has been minimized.

Copy link

gsaathof commented Jan 16, 2019

This was really helpful! It worked great.

@MatiasJAco

This comment has been minimized.

Copy link

MatiasJAco commented Jan 17, 2019

Nice and clean.

@Shannonkay123

This comment has been minimized.

Copy link

Shannonkay123 commented Jan 18, 2019

I've done this several times and I'm not getting results! Help!

@thepankajpiro

This comment has been minimized.

Copy link

thepankajpiro commented Jan 26, 2019

thanks

@techhubmyanmar

This comment has been minimized.

Copy link

techhubmyanmar commented Jan 30, 2019

Helpful

@zawtone

This comment has been minimized.

Copy link

zawtone commented Feb 1, 2019

thanks

@XueWeiHuang

This comment has been minimized.

Copy link

XueWeiHuang commented Feb 6, 2019

Awesome!
Thanks!

@Smithemyjer

This comment has been minimized.

Copy link

Smithemyjer commented Feb 16, 2019

so for each new repository we need a new username?
repository creation failed name already exists on this account. Yeah because I did a tutorial with my user name. It says the name is really important and to name it my user name.github.io already did that. I just want to publish my files.

@brookjordan

This comment has been minimized.

Copy link

brookjordan commented Mar 3, 2019

Needed this.
Thank you.

@devneidu

This comment has been minimized.

Copy link

devneidu commented Mar 28, 2019

thanks.
I have a quick question.
What if i want to host like 3 different static pages am i to create 2 other accounts??

@IddrissAjanak

This comment has been minimized.

Copy link

IddrissAjanak commented Mar 30, 2019

I like it thanks

@DrewShults

This comment has been minimized.

Copy link

DrewShults commented Apr 23, 2019

I am literally doing everything exactly as described and I am still getting a 404. Makes no sense. I haven't even added pictures to it because it didn't originally work and still not working. Harder than just emailing a dang folder to someone with the website.

@AadhithyanKarthick

This comment has been minimized.

Copy link

AadhithyanKarthick commented Apr 27, 2019

for databases what we have to do?

@JoswaR84

This comment has been minimized.

Copy link

JoswaR84 commented May 1, 2019

TY!

@mks999

This comment has been minimized.

Copy link

mks999 commented May 11, 2019

image
Cant publish, shows above error

@jonasbits

This comment has been minimized.

Copy link

jonasbits commented May 20, 2019

@mks999 did you try to Clone with SSH? git@github.com/theRestOfYourURL

@rohitsinghshan

This comment has been minimized.

Copy link

rohitsinghshan commented Jun 12, 2019

I have followed same steps but I'm getting error page not found
image
https://rohitsinghshaan.github.io/

@TylerFisher

This comment has been minimized.

Copy link
Owner Author

TylerFisher commented Jun 14, 2019

Hey folks, no idea if these instructions are still good. Github has changed a lot since I wrote them! Consult the Github docs.

@theeEprojects

This comment has been minimized.

Copy link

theeEprojects commented Jun 17, 2019

@nomiullah

This comment has been minimized.

Copy link

nomiullah commented Jul 9, 2019

Thanks CAMP...!

@Antkeo1

This comment has been minimized.

Copy link

Antkeo1 commented Aug 20, 2019

cant find the publish repo button

@kennycyphers1

This comment has been minimized.

Copy link

kennycyphers1 commented Sep 2, 2019

Works Great. Thanks a lot.

@gabaggrey

This comment has been minimized.

Copy link

gabaggrey commented Sep 5, 2019

Hello, Please this does not work.

@SofianeMeziani

This comment has been minimized.

Copy link

SofianeMeziani commented Sep 7, 2019

Thanks !

@souravendra

This comment has been minimized.

Copy link

souravendra commented Oct 21, 2019

Exactly what I was looking for thank you so much!

@FatimaVelic

This comment has been minimized.

Copy link

FatimaVelic commented Oct 25, 2019

The desktop app won't install on macOS Catalina.
It says: App needs to be updated. Contact the developer.
Is there a new supported version coming out soon?

@dkhandalsarvika

This comment has been minimized.

Copy link

dkhandalsarvika commented Nov 1, 2019

The custom domain for your GitHub Pages site is pointed at an outdated IP address. You must update your site's DNS records if you'd like it to be available via your custom domain. For more information, see ( https://help.github.com/en/github/working-with-github-pages/configuring-a-custom-domain-for-your-github-pages-site).

To create an A record, point your apex domain to the IP addresses for GitHub Pages.

185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153

@souravendra

This comment has been minimized.

Copy link

souravendra commented Nov 10, 2019

Just adding a comment - after doing everything mentioned in the tutorial, remember to select any Jekyll theme under the repo settings, otherwise you'll get a 404 error.

@codeinfluencer

This comment has been minimized.

Copy link

codeinfluencer commented Nov 27, 2019

Is it possible to host a site that requires a database on GitHub?

@saifvoice

This comment has been minimized.

Copy link

saifvoice commented Dec 14, 2019

@mks999 did you try to Clone with SSH? git@github.com/theRestOfYourURL

Yes

@dbathaei

This comment has been minimized.

Copy link

dbathaei commented Dec 20, 2019

Will the website still be published if the repo is private ?

@jithu12

This comment has been minimized.

Copy link

jithu12 commented Dec 27, 2019

anyway to remove .github from username.gihub.io?

@ashleygoury

This comment has been minimized.

Copy link

ashleygoury commented Jan 7, 2020

thanks

@coolsasindu

This comment has been minimized.

Copy link

coolsasindu commented Jan 8, 2020

wo wo

@christophersesugh

This comment has been minimized.

Copy link

christophersesugh commented Jan 18, 2020

This is cool. Thank you.

@FotieMConstant

This comment has been minimized.

Copy link

FotieMConstant commented Jan 23, 2020

Thanks for this but how do I actually host a web app project using Github pages

@prasanthkumar2392

This comment has been minimized.

Copy link

prasanthkumar2392 commented Jan 28, 2020

Wow.. Thank you so much

@mattrobmattrob

This comment has been minimized.

Copy link

mattrobmattrob commented Feb 5, 2020

Great instructions specifically for Google Domains: https://dev.to/trentyang/how-to-setup-google-domain-for-github-pages-1p58

@AbdulWasayKhan

This comment has been minimized.

Copy link

AbdulWasayKhan commented Feb 8, 2020

Will the website still be published if the repo is private ?

Yes

@AbdulWasayKhan

This comment has been minimized.

Copy link

AbdulWasayKhan commented Feb 8, 2020

anyway to remove .github from username.gihub.io?

You need to buy a separate domain name, I bought from 1&1, but that takes $1 in the first year than it takes $15 in the following years. You can transfer to other providers too.
After you are done buying it now you can link that to your github.io. So whenever a person tries to access your website through typing usrname.giithub.io or the domain name for e.g abc.com it will bring to you to abc.com
There are few steps in order to do that for e.g you need to create a CNAME file in github and put your domain name that you bought etc.
I hope this helps!

@sedrip

This comment has been minimized.

Copy link

sedrip commented Mar 20, 2020

Instructions still work, but make sure to make your file public before you submit under the settings option or youll get a 404 message. @AbdulWassayKhan I had to turn my settings public before I could see it live.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.