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 JubrilJuma commented Nov 26, 2017

Thank you!

@cipriandraghici93

This comment has been minimized.

Copy link

@cipriandraghici93 cipriandraghici93 commented Jan 14, 2018

Great, thanks !

@ttngocthao

This comment has been minimized.

Copy link

@ttngocthao ttngocthao commented Feb 14, 2018

Thanks, that is very helpful!

@mdfaizulislam

This comment has been minimized.

Copy link

@mdfaizulislam mdfaizulislam commented Feb 19, 2018

Great!
Thanks a lot.

@tobioye88

This comment has been minimized.

Copy link

@tobioye88 tobioye88 commented Feb 22, 2018

I should try this some time

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Feb 23, 2018

this helps.

@nchos88

This comment has been minimized.

Copy link

@nchos88 nchos88 commented Feb 26, 2018

Nice post! thanks a lot!

@AaronDrobek

This comment has been minimized.

Copy link

@AaronDrobek 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 SuharshTyagii commented Mar 31, 2018

TYTYTYTY

@mapuchila

This comment has been minimized.

Copy link

@mapuchila mapuchila commented Apr 5, 2018

Many thanks!

@gamesforbryan

This comment has been minimized.

Copy link

@gamesforbryan 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 EOussama commented Apr 29, 2018

This was a great help, thank you.

@balaji961

This comment has been minimized.

Copy link

@balaji961 balaji961 commented May 2, 2018

Great piece of work

@Coder-ACJHP

This comment has been minimized.

Copy link

@Coder-ACJHP Coder-ACJHP commented May 5, 2018

Thank you so much

@frankovo

This comment has been minimized.

Copy link

@frankovo frankovo commented May 12, 2018

Awesome work. Big grazie.

@bestorw01

This comment has been minimized.

Copy link

@bestorw01 bestorw01 commented May 16, 2018

Thank you so Much

@ogekingsley

This comment has been minimized.

Copy link

@ogekingsley ogekingsley commented May 19, 2018

Thank you very much...

@foresteps

This comment has been minimized.

Copy link

@foresteps 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 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 DwGonzalez commented Jun 6, 2018

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

@Jenn122783

This comment has been minimized.

Copy link

@Jenn122783 Jenn122783 commented Jun 9, 2018

Super helpful! Appreciated!

@1Dineshkumar

This comment has been minimized.

Copy link

@1Dineshkumar 1Dineshkumar commented Jun 16, 2018

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

@sislinigeria

This comment has been minimized.

Copy link

@sislinigeria sislinigeria commented Jun 25, 2018

I love this. Thank you.

@solomonaleka

This comment has been minimized.

Copy link

@solomonaleka solomonaleka commented Jun 26, 2018

That was helpful

@Mercien

This comment has been minimized.

Copy link

@Mercien Mercien commented Jun 27, 2018

Cool, pretty helpful

@antoncoding

This comment has been minimized.

Copy link

@antoncoding antoncoding commented Jul 1, 2018

thanks for the tips!

@nimeish811

This comment has been minimized.

Copy link

@nimeish811 nimeish811 commented Jul 13, 2018

thanks for tips

@leenMalka

This comment has been minimized.

Copy link

@leenMalka leenMalka commented Jul 30, 2018

you are life saver 👍

@cdoffx

This comment has been minimized.

Copy link

@cdoffx cdoffx commented Jul 31, 2018

How about hosting a nodejs page?

@faizaldong

This comment has been minimized.

Copy link

@faizaldong 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 pemeraldy commented Aug 27, 2018

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

@praven15

This comment has been minimized.

Copy link

@praven15 praven15 commented Oct 2, 2018

gg

@Oluwa-nifemi

This comment has been minimized.

Copy link

@Oluwa-nifemi 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 gsaathof commented Jan 16, 2019

This was really helpful! It worked great.

@MatiasJAco

This comment has been minimized.

Copy link

@MatiasJAco MatiasJAco commented Jan 17, 2019

Nice and clean.

@Shannonkay123

This comment has been minimized.

Copy link

@Shannonkay123 Shannonkay123 commented Jan 18, 2019

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

@thepankajtech

This comment has been minimized.

Copy link

@thepankajtech thepankajtech commented Jan 26, 2019

thanks

@techhubmyanmar

This comment has been minimized.

Copy link

@techhubmyanmar techhubmyanmar commented Jan 30, 2019

Helpful

@zawtone

This comment has been minimized.

Copy link

@zawtone zawtone commented Feb 1, 2019

thanks

@XueWeiHuang

This comment has been minimized.

Copy link

@XueWeiHuang XueWeiHuang commented Feb 6, 2019

Awesome!
Thanks!

@Smithemyjer

This comment has been minimized.

Copy link

@Smithemyjer 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 brookjordan commented Mar 3, 2019

Needed this.
Thank you.

@devneidu

This comment has been minimized.

Copy link

@devneidu 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 IddrissAjanak commented Mar 30, 2019

I like it thanks

@DrewShults

This comment has been minimized.

Copy link

@DrewShults 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 AadhithyanKarthick commented Apr 27, 2019

for databases what we have to do?

@jgram925

This comment has been minimized.

Copy link

@jgram925 jgram925 commented May 1, 2019

TY!

@mks999

This comment has been minimized.

Copy link

@mks999 mks999 commented May 11, 2019

image
Cant publish, shows above error

@jonasbits

This comment has been minimized.

Copy link

@jonasbits 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 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 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 theeEprojects commented Jun 17, 2019

@nomiullah

This comment has been minimized.

Copy link

@nomiullah nomiullah commented Jul 9, 2019

Thanks CAMP...!

@Antkeo1

This comment has been minimized.

Copy link

@Antkeo1 Antkeo1 commented Aug 20, 2019

cant find the publish repo button

@kennycyphers1

This comment has been minimized.

Copy link

@kennycyphers1 kennycyphers1 commented Sep 2, 2019

Works Great. Thanks a lot.

@gabaggrey

This comment has been minimized.

Copy link

@gabaggrey gabaggrey commented Sep 5, 2019

Hello, Please this does not work.

@SofianeMeziani

This comment has been minimized.

Copy link

@SofianeMeziani SofianeMeziani commented Sep 7, 2019

Thanks !

@souravendra

This comment has been minimized.

Copy link

@souravendra souravendra commented Oct 21, 2019

Exactly what I was looking for thank you so much!

@FatimaVelic

This comment has been minimized.

Copy link

@FatimaVelic 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 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 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.

@thecodeinfluencer

This comment has been minimized.

Copy link

@thecodeinfluencer thecodeinfluencer 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 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 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 jithu12 commented Dec 27, 2019

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

@ashleygoury

This comment has been minimized.

Copy link

@ashleygoury ashleygoury commented Jan 7, 2020

thanks

@coolsasindu

This comment has been minimized.

Copy link

@coolsasindu coolsasindu commented Jan 8, 2020

wo wo

@christophersesugh

This comment has been minimized.

Copy link

@christophersesugh christophersesugh commented Jan 18, 2020

This is cool. Thank you.

@FotieMConstant

This comment has been minimized.

Copy link

@FotieMConstant 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 prasanthkumar2392 commented Jan 28, 2020

Wow.. Thank you so much

@mattrobmattrob

This comment has been minimized.

Copy link

@mattrobmattrob 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 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 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 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.

@MarianoVera

This comment has been minimized.

Copy link

@MarianoVera MarianoVera commented Apr 18, 2020

Oh great. Thank you!

@mendes-jom

This comment has been minimized.

Copy link

@mendes-jom mendes-jom commented Apr 22, 2020

Thanks a lot. Useful.

@AbdulWasayKhan

This comment has been minimized.

Copy link

@AbdulWasayKhan AbdulWasayKhan commented Apr 23, 2020

@sedrip Okay, great!! I see. For me firstly it was public I believe and when the website was live, I turned my repository to private. Currently my repository is private.

@AbdulWasayKhan

This comment has been minimized.

Copy link

@AbdulWasayKhan AbdulWasayKhan commented Apr 23, 2020

@dbathaei, please have a look at sedrip thread. In order to see your website live make sure you turn your repository to public and then try to see your website.

@saikrishnaRavirala

This comment has been minimized.

Copy link

@saikrishnaRavirala saikrishnaRavirala commented Jun 6, 2020

tqu

@joeeeeeewww

This comment has been minimized.

Copy link

@joeeeeeewww joeeeeeewww commented Jul 8, 2020

I like this

@albertejuku

This comment has been minimized.

Copy link

@albertejuku albertejuku commented Jul 19, 2020

Thank you

@signalogic

This comment has been minimized.

Copy link

@signalogic signalogic commented Aug 18, 2020

A related question -- is there any way to upload an .html file directly to github.com/account_name ? I want to put a Google Search Console (GSC) provided .html verification file there

@UtkarshM-hub

This comment has been minimized.

Copy link

@UtkarshM-hub UtkarshM-hub commented Sep 11, 2020

thanks

@Abbaskhurram255

This comment has been minimized.

Copy link

@Abbaskhurram255 Abbaskhurram255 commented Oct 1, 2020

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

Make sure your repo is public. Otherwise your website won't create and show a 404 error just like the one that occurred when you tried to create your site without even making your repo public

@CoderHub-tech

This comment has been minimized.

Copy link

@CoderHub-tech CoderHub-tech commented Oct 13, 2020

this work

@thestellartech

This comment has been minimized.

Copy link

@thestellartech thestellartech commented Oct 19, 2020

hi ,
my repo is in public, but still i am getting 404 error once in a day. After refreshing (10 mins) again i can see my website. why i am getting this error i couldn't understand. Any help will be appreciable

@manu223

This comment has been minimized.

@derek-hoogewerf

This comment has been minimized.

Copy link

@derek-hoogewerf derek-hoogewerf commented Oct 30, 2020

@manu233 you need to place your index file inside /docs or /(root) whichever one you chose. You can not place it in a sub folder. I had the same issue. Or else you can use GitHub to generate an index.mg page for you which you can edit.

@im7srar

This comment has been minimized.

Copy link

@im7srar im7srar commented Nov 5, 2020

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

Make sure your repo is public. Otherwise your website won't create and show a 404 error just like the one that occurred when you tried to create your site without even making your repo public

Hey, i have faced the same error when i load my website. I kept the repo PRIVATE but after i changed to PUBLIC and still i have the same error 404
404 error

http://im7srar.github.io/

@DevendraKshirsagar

This comment has been minimized.

Copy link

@DevendraKshirsagar DevendraKshirsagar commented Dec 10, 2020

isnt the desktopapp is available for ubuntu ??

@Abbaskhurram255

This comment has been minimized.

Copy link

@Abbaskhurram255 Abbaskhurram255 commented Jan 1, 2021

Add a _redirects file, y'all
How? Take a look at this _redirects file I've saved at the root dir of my site to redirect users from / (root) to /index.html

@MaheshTechnicals

This comment has been minimized.

Copy link

@MaheshTechnicals MaheshTechnicals commented Jan 2, 2021

Actually I have great detailed information about that topic. With this guide you can Host A Website On GitHub using Android Phone. You can use custom Domain As well.

@sagnik1511

This comment has been minimized.

Copy link

@sagnik1511 sagnik1511 commented Jan 10, 2021

Thanks ! It launched in a second :D

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Feb 6, 2021

CAN ANYONE ASSIST ME PLEASE? GITHUB IS NOT PUBLISHING MY WEBSITE, EVEN AFTER I CLICKED PUBLISH. WHY IS THIS PLATFORM SO DIFFICULT TO USE?

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Feb 6, 2021

@sagnik1511 can you help me? or anyone else?

@sagnik1511

This comment has been minimized.

Copy link

@sagnik1511 sagnik1511 commented Feb 7, 2021

@sagnik1511 can you help me? or anyone else?
make a repo "username.github.io" and then add or create the html file in it (name it "index.html" .
You can view my repo on the same topic.
And at last try to visit the active environments , then you can find your webpage is working or not.

@sahil2199

This comment has been minimized.

Copy link

@sahil2199 sahil2199 commented Feb 8, 2021

Thank you!

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

Make sure your repo is public. Otherwise your website won't create and show a 404 error just like the one that occurred when you tried to create your site without even making your repo public

Hey, i have faced the same error when i load my website. I kept the repo PRIVATE but after i changed to PUBLIC and still i have the same error 404
404 error
Hey im7srar can you please help me i am still getting 404 error, though i changed to PUBLIC
http://im7srar.github.io/

@utsav642

This comment has been minimized.

Copy link

@utsav642 utsav642 commented Feb 15, 2021

"main html file should be named as "index.html".
the only point I was missing...

Thank You!

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Feb 24, 2021

Excellent article. I could absolute figure out NOTHING!

@Anubhav-developr

This comment has been minimized.

Copy link

@Anubhav-developr Anubhav-developr commented Apr 13, 2021

great value addition for developers

@Ndohjapan

This comment has been minimized.

Copy link

@Ndohjapan Ndohjapan commented Apr 13, 2021

Thanks a lot.

@Ndohjapan

This comment has been minimized.

Copy link

@Ndohjapan Ndohjapan commented Apr 13, 2021

Sorry, I don't even understand what to do.

Which part don't you understand, maybe I can explain better.

@KKTHEBOSS123

This comment has been minimized.

Copy link

@KKTHEBOSS123 KKTHEBOSS123 commented May 18, 2021

tell me how to do without downloading github

@ewobe

This comment has been minimized.

Copy link

@ewobe ewobe commented May 18, 2021

how do i create an index page on github, pls. help

@Ndohjapan

This comment has been minimized.

Copy link

@Ndohjapan Ndohjapan commented May 18, 2021

@Ndohjapan

This comment has been minimized.

Copy link

@Ndohjapan Ndohjapan commented May 18, 2021

@info-monir

This comment has been minimized.

Copy link

@info-monir info-monir commented Jun 18, 2021

can anyone tell me how can I get this url for my website username.github.io ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment