Search code examples
githubgithub-pages

Add Custom Domains in GitHub Pages


How to change http://user.github.io/repo to http://customdomain.com/myrepo in GitHub Pages?

I tried going through the documentation but it didn't talk about this case.


Solution

  • AFAIK, to have a customized domain name, you have to create a file named CNAME in the root directory of your GitHub repository.

    The file content should be something like this (this is just an example):

    my-website.com
    

    Instead of using https://user.github.io/<repo-name>, it will now redirect to my-website.com.
    You still have to make a few other changes for this to work. Check out the GitHub Docs on this topic.