Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Free Hosting on GitHub

Free Hosting on GitHub

This guide will take you from zero webserver knowledge, to having your own free site hosted on GitHub. The only non-free bit is registering a domain name, which can be as cheap as $5/year.

This guide uses CrazyDomains as the Registrar, FreeDNS as the DNS, and GitHub as the Webserver.


1) Domain Registration and Setup

The Domain Name Registrar is where you register your domain name, This is the only not free step. Your registrar needs to know which DNS Server will associate the Domain Name with a WebServer. I've got mine with CrazyDomains, as they offer the cheapest .com.au domains.

  1. Create an account, chuck in your payment details, etc.
  2. Register your domain(s)
  3. Set your domains Name Servers to ns1.afraid.org, ns2, ns3, and ns4.

2) Setup your DNS

Edit: Ignore this section and use CloudFlare instead. It's free, it's a DNS, It's also a CDN, and it's also easier.

I use FreeDNS, cause it's free, and doesn't look too dodgy.

  1. Set up an account, login
  2. Go to Domains -> Add a Domain to FreeDNS Domain: yourdomain.com Shared State: Shared: Public
  3. Go to Domains -> yourdomain.com -> Manage
  4. Click the Add button at the top-right Type: A Subdomain: blank Domain: yourdomain.com (public)(broken!) Destination: 192.30.252.153 Wildcard: ticked
  5. Click the Add button next to yourdomain.com again, same settings as last time, but this time use the ip: 192.30.252.154

3) Set Up your Website on GitHub

  1. go to GitHub.com, create an account, and login
  2. Create a new Repository, mame it yourdomain.com, leave it as Public, and tick `Initialize this repository with a README``
  3. Click Settings (in the right-middle -- for the repo, not for your account)
  4. Under Github Pages click Automatic page generator
  5. Make any changes you like, put in a Google Analytics ID if you want awesome free stats, click Continue to layouts
  6. Choose a theme, or just go with the default and change it later. Click Publish Page
  7. Your page can now be viewed at http://<your github username>.github.io/<your repo name>/
  8. Back on your repo's page, click Branch: master and change to the gh-pages branch
  9. Next to the Branch selector, it will show yourdomain.com, followed by a / and a +. Click the + to create a new file.
  10. Name the file CNAME and put yourdomain.com inside as the contents, click Commit new file to save it.

--

That's it! Everything's set up!

It can take up to 24 hours for the Domain Name to propogate, sometimes it only takes a few minutes thoughu. Until then browsing to yourdomain.com will just return an error. If you're really impatient you can add it to your computer's hosts file, otherwise just wait it out.


Tips

  • Settings -> Default branch: gh-pages
@deanrather

This comment has been minimized.

Copy link
Owner Author

@deanrather deanrather commented Jun 12, 2015

Todo: use CloudFlare instead of FreeDNS

@alexandlazaris

This comment has been minimized.

Copy link

@alexandlazaris alexandlazaris commented Jun 9, 2017

Create a new Repository, **_mame_** it yourdomain.com, leave it as Public, and tick `Initialize this repository with a README``

UNACCEPTABLE

@josenavento

This comment has been minimized.

Copy link

@josenavento josenavento commented Jun 27, 2017

Can you also host subdomains?

@JendenJulkamri

This comment has been minimized.

Copy link

@JendenJulkamri JendenJulkamri commented Aug 26, 2017

My Websiite

@kmbuisha

This comment has been minimized.

Copy link

@kmbuisha kmbuisha commented Sep 21, 2017

This method no-longer works. It doesn't display your page anymore but rather advertisers the theme you selected eventhough you have published your page. Is there an updated method that anyone knows, it will be very much appreciated.

@thepaintedbeat1

This comment has been minimized.

Copy link

@thepaintedbeat1 thepaintedbeat1 commented Nov 6, 2017

Looking to use github as host already have a domain will google domains thoughts?

@interceptnet

This comment has been minimized.

Copy link

@interceptnet interceptnet commented Nov 7, 2017

any thoughts on hosting ecommerce website?

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Nov 18, 2017

Will be an actual website for the public to gain access too? I'm trying to create a shopping website like Amazon and other companies

@deanrather

This comment has been minimized.

Copy link
Owner Author

@deanrather deanrather commented Dec 5, 2017

Wow, didn't realise there were actual comments on here, haha!
I might update this today, but yeah: the exact instructions for the gh-pages stuff has changed, the nameservers are wrong 'cause they're pointing to freedns instad of cloudflare, and I haven't documented cloudflare. so it's a bit... almost all wrong :)

@VaasKahnGrim

This comment has been minimized.

Copy link

@VaasKahnGrim VaasKahnGrim commented Dec 30, 2017

possibility for any mySQL? just curious

@justinfarmer14

This comment has been minimized.

Copy link

@justinfarmer14 justinfarmer14 commented Jan 26, 2018

@cactusadmin nope

@Atomica-1

This comment has been minimized.

Copy link

@Atomica-1 Atomica-1 commented Apr 21, 2018

It says step 3. Set your domains Name Servers to ns1.afraid.org, ns2, ns3, and ns4.

Now its asking for ip address?

@SakhirAtwi

This comment has been minimized.

Copy link

@SakhirAtwi SakhirAtwi commented Aug 5, 2018

I have a site up and running on github pages, its 2018 man better option are out in there for gh-pages deployment.

In my opinion your best bet in to use godaddy for domain(They are the best), cloudflare for nameserver, use any IP of pages.github.io for A name record and the casual uploading of your site on your repo, private repo would be better if you plan to be a lil bit pro.
And boom, you are good to go.

Reasons for using cloudflare:

Free DDoS protection,
Free Nameservers,
Free static caching

Site that I hosted,
alnisaarifwala.com

@juna-github

This comment has been minimized.

Copy link

@juna-github juna-github commented Jun 26, 2019

my websit

@NotChristopherSun

This comment has been minimized.

Copy link

@NotChristopherSun NotChristopherSun commented Apr 7, 2020

Getting a domain from Google Domains is cheaper than CrazyDomains.

@alechash

This comment has been minimized.

Copy link

@alechash alechash commented Aug 12, 2020

Can you also host subdomains?

Yes you can @josenavento

@igor041

This comment has been minimized.

Copy link

@igor041 igor041 commented Sep 2, 2020

You might want to take this page down since none of it is accurate anymore

@lerryberry

This comment has been minimized.

Copy link

@lerryberry lerryberry commented Oct 28, 2020

how duz you make my web sit? it's been standing all day meny thanks

@kaitokun24

This comment has been minimized.

@lit-devs

This comment has been minimized.

Copy link

@lit-devs lit-devs commented May 2, 2021

Hey this is so good and worked well but i have a query is that can we place our own web pages in it rather than theme?
Thanks!

@alechash

This comment has been minimized.

Copy link

@alechash alechash commented May 2, 2021

@lit-devs yea you can, just make sure to have an index.html for the root, and a 404.html for 404 pages.

@cforbin1

This comment has been minimized.

Copy link

@cforbin1 cforbin1 commented May 6, 2021

You didn't mention that you're assuming the user wants to version control the source code for a website.
I was halfway into doing all the steps before I realized this.
Because of it, I put my company's IT department through some hoop jumping to get me a test domain that I won't end up needing.

Bottom line, you need to warn the reader early on:
There is NO NEED for a domain name if you are trying out GitHub but are not maintaining a website!

("Set up your website on GitHub" doesn't mean setting up some views of your project in GitHub. The O.P. means literally "you have a website, now put the source for it in GitHub.")

@786-Barbershop

This comment has been minimized.

Copy link

@786-Barbershop 786-Barbershop commented May 22, 2021

Hey this is so good and worked well but i have a query is that can we place our own web pages in it rather than theme?
Thanks!

Yeah same question here plz someone Answer as soon as possible....

@alechash

This comment has been minimized.

Copy link

@alechash alechash commented May 22, 2021

Hey this is so good and worked well but i have a query is that can we place our own web pages in it rather than theme?
Thanks!

Yeah same question here plz someone Answer as soon as possible....

Hey! Yeah, you can. Just put an index.html in the root as the main page.

For 404 pages, you can create a 404.html for all 404 pages.

For anything else like other html, css, js, img, and other files, just create those and link them relatively and you’ll be all set!

Thanks,
If you have anymore questions, just ask, you can also mention me or other people!

@mjon

This comment has been minimized.

Copy link

@mjon mjon commented Aug 31, 2021

Thanks. This was all super helpful. I got CrazyDomains + Cloudflare + Github Pages up and running, just with index.html (I'll add on a Jekyll theme later). The big thing to note is that "It can take up to 24 hours for the Domain Name to propagate". I had to wait overnight before all the pieces clicked into place for mine.

I was confused for a while about the "Enforce HTTPS" check box on the Github's Pages Settings. In the end, I read that that I could safely keep that unchecked because Cloudflare takes care of that.

@alechash

This comment has been minimized.

Copy link

@alechash alechash commented Sep 1, 2021

Awesome! I use Cloudflare for all my domains and the checkbox is disabled on all of them

@kruz26

This comment has been minimized.

Copy link

@kruz26 kruz26 commented Nov 11, 2021

Todo: use CloudFlare instead of FreeDNS

bro please do you know where i can get a free domain like example.com or example.net for free without any verification , 🙏

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