DEV Community

How to Add a Custom Domain to GitHub Pages (Hostinger Edition)

Sidharth Mohanty on July 04, 2023

I recently finished my portfolio website, and it was a dream come true to have a small space of my own on the internet. To make this happen, I boug...
Collapse
 
ismaildns profile image
Ismail

For this step Step 3: Create two new CNAME records, how about if my website url in GitHub pages is username. github.io/reponame

Should the record point to username. github.io/reponame then or just username. github.io

Collapse
 
sidmohanty11 profile image
Sidharth Mohanty

I've not tried it, but I think it should be username.github.io/reponame if reponame is not == username.github.io/reponame

Collapse
 
ismaildns profile image
Ismail

Thank you but I already solved it.

DNS CNAME records are designed to point to domain names, not to specific paths or URLs within a domain. In this case: username.github.io

What I did to solve this is updating my package.json file (my website is a React app).

I updated this:
"homepage": "username.github.io/reponame/",
to
"homepage": "https://my_custom_domain.com/",

Thread Thread
 
adleeafif profile image
Adlee Afif

hey just wondering, aside from the updating the package.json, what did you set for the DNS setting in the Hostinger? Is it the same with the post? Thanks!

Collapse
 
limarich profile image
Richard Lima Ribeiro

Thanks! It works very well!👌

Collapse
 
mrjeanmichell profile image
Jean Michell

sweet! :) thank you.
just added mine: copycommands.com

Collapse
 
sidmohanty11 profile image
Sidharth Mohanty

Wow! Looks awesome and helpful!

Collapse
 
lucksinia profile image
Lucksinia

Hostinger is salty when I'm trying to add more then one IP... Nothing to worry about? Genuine question here.

Collapse
 
octapf profile image
Octavio Frangipani

Same for me! But added them anyway

Collapse
 
owoleya profile image
pyotrleya

are there any changes to the nameservers Hostinger uses or do I leave them as is?

Collapse
 
sidmohanty11 profile image
Sidharth Mohanty

I think if you're using Hostinger as the provider, you can leave them as it is