How to Host Your Website With a Custom Domain for Free

Alan Chen
Alan Chen
Jul 25, 2020 · 3 min read
Image for post
Image for post

A common misconception that many (including myself in the past) have is that you need to pay money to host a website with a custom domain. That couldn’t be further from the truth.

Hosting Your Website

So you’re satisfied with how your website looks on localhost. Now what? If you haven’t got a GitHub account, go ahead and make one. Then, create a new repository. You can choose to make it public or private.

Image for post
Image for post
You can give your repository any name, but conventionally for personal/portfolio websites, people name it <username>.github.io

If you are familiar with the command line and GitHub, go ahead and push your code. If not, simply click “upload an existing file”

When you upload or push your files, be sure that your index.html is in the root directory. That is, do not have it nested inside any folders. Once you have uploaded your files, go into your “Settings” tab in the repository.

If you scroll down, you’ll see a “GitHub Pages” section. Go ahead and change the source to the master branch.

Image for post
Image for post

Once this is done, refresh the page and you’ll see “Your site is ready to be published at *Repository URL*”. If you wait a minute or two and refresh, that message will change to “ Your site is published at *Repository URL*”. Click that link and make sure your page is up.

Getting a Custom Domain

This step is fairly easy. Head to Freenom and create an account, following the instructions. Once you have created an account, register a new domain here. Find your domain, and check out.

Image for post
Image for post
Make sure your domain is FREE of charges

I would suggest getting your domain for 12 months so you don’t have to re-register it for another year. When you’re checking out, it may ask you to sign in again. Do that, and find your way back to the checkout page. It should NOT ask you for any credit card details.

Once that is done, go to services -> My Domains -> Manage Domain -> Manage Freenom DNS. Add “A” records to the following domains:

185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
Image for post
Image for post
Optional: add CNAME from WWW to your custom domain. This will allow www.<yourdomain>.com to work with or without the “www”

Once that is done, go to your GitHub pages settings again, and add your custom domain under “Custom domain” and hit save.

Image for post
Image for post

If you get this warning, don’t worry. Give it some time and head over to our custom domain. The process can take up to 24 hours (it usually just takes a minute or two) for your domain to link to your Github pages.

Image for post
Image for post

Voila! Now you have your own website hosted with a custom domain, and you didn’t spend a single penny to do it. Check out the website I published in this tutorial, as well as the repository.

The Startup

Medium's largest active publication, followed by +773K people. Follow to join our community.

Alan Chen

Written by

Alan Chen

Computer Science @ New York University | Courant Institute of Mathematical Sciences

The Startup

Medium's largest active publication, followed by +773K people. Follow to join our community.

Alan Chen

Written by

Alan Chen

Computer Science @ New York University | Courant Institute of Mathematical Sciences

The Startup

Medium's largest active publication, followed by +773K people. Follow to join our community.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store