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.

@sagnik1511
Copy link

sagnik1511 commented Jan 10, 2021

Thanks ! It launched in a second :D

Copy link

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?

Copy link

ghost commented Feb 6, 2021

@sagnik1511 can you help me? or anyone else?

@sagnik1511
Copy link

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
Copy link

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
Copy link

utsav642 commented Feb 15, 2021

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

Thank You!

Copy link

ghost commented Feb 24, 2021

Excellent article. I could absolute figure out NOTHING!

@Anubhav-developr
Copy link

Anubhav-developr commented Apr 13, 2021

great value addition for developers

@Ndohjapan
Copy link

Ndohjapan commented Apr 13, 2021

Thanks a lot.

@Ndohjapan
Copy link

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
Copy link

KKTHEBOSS123 commented May 18, 2021

tell me how to do without downloading github

@ewobe
Copy link

ewobe commented May 18, 2021

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

@Ndohjapan
Copy link

Ndohjapan commented May 18, 2021

@Ndohjapan
Copy link

Ndohjapan commented May 18, 2021

@monir-info
Copy link

monir-info commented Jun 18, 2021

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

@Richard-Cao226
Copy link

Richard-Cao226 commented Oct 24, 2021

For the backend part of my code to work, index.html needs to be in a subfolder instead of the root directory. Is there a way to host the website in this case?

@sagnik1511
Copy link

sagnik1511 commented Oct 24, 2021

For the backend part of my code to work, index.html needs to be in a subfolder instead of the root directory. Is there a way to host the website in this case?

You just need to specify the path then like https://{user_name}.github.io/{folder_location_of_index.html}/

@Richard-Cao226
Copy link

Richard-Cao226 commented Oct 24, 2021

For the backend part of my code to work, index.html needs to be in a subfolder instead of the root directory. Is there a way to host the website in this case?

You just need to specify the path then like https://{user_name}.github.io/{folder_location_of_index.html}/

Thanks! If I were to use a custom domain, would the path then be https://{custom_domain}/{folder_location_of_index.html}/?

@sagnik1511
Copy link

sagnik1511 commented Oct 24, 2021

For the backend part of my code to work, index.html needs to be in a subfolder instead of the root directory. Is there a way to host the website in this case?

You just need to specify the path then like https://{user_name}.github.io/{folder_location_of_index.html}/

Thanks! If I were to use a custom domain, would the path then be https://{custom_domain}/{folder_location_of_index.html}/?

I guess that would be appropriate in general.

@yxuansu
Copy link

yxuansu commented Nov 13, 2021

Super helpful! Big thanks!

@dhiraj80
Copy link

dhiraj80 commented Nov 26, 2021

thanks

@labeveryday
Copy link

labeveryday commented Jan 9, 2022

You rock!

@glennhefley
Copy link

glennhefley commented Jan 16, 2022

Sweet! Thank you so much

@BARBARBoyyHD
Copy link

BARBARBoyyHD commented Jan 29, 2022

my page keep appearing 404 i have already followed everystep but still 404 what the fk is going on ??

@kernel52
Copy link

kernel52 commented Jan 30, 2022

@BARBARBoyyHD you might want to share some extra info about your issue. even maybe start a new thread?

I'll go from the start assuming nothing and you can tell me how far you've reached down the process

Have you read the guides?

Assuming you created one, what is the name of your repository you try to publish online? [repo_name]

From above you can see the two basic debug steps.
Are the pages option activated?
Is the repo you created public?

To begin with the webpages, maybe you can start first by creating a README.md file on the root folder of your repo.
You should be able to see it using a link constructed as follows https://{user_name}.github.io/{repo_name}/

In your case it should be something like https://BARBARBoyyHD.github.io/{repo_name}/

Give it a try and provide feedback and info.
And give it some time, as there is always some delay in pages and changes appearing.

Caching is good but needs patience when updating content.

@Keshera
Copy link

Keshera commented Mar 12, 2022

I got it to work after selecting a 'Source' from the GitHub Pages (Settings - Pages - Source). Once you select the source, the URL for your website will automatically appear on Settings - Pages.

@GangCheng0619
Copy link

GangCheng0619 commented Mar 31, 2022

Hello stop discussing.

@manu223
Copy link

manu223 commented Mar 31, 2022

@icud
Copy link

icud commented Apr 24, 2022

Can you share how to..

I'm currently using a mobile phone.

@manu223
Copy link

manu223 commented Apr 24, 2022

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