Tuesday, April 7, 2015

custom domain with github pages

I recently bought a domain name from 1and1.com. I was planning to host my static files on github pages. After I checked my page on github I saw that responsive design works. But when I do the config (on 1and1) for forwarding my domain name (sezinkarli.com) to my github page (sezinkarli.github.io), I saw that responsiveness is gone. Nothing changes if I change the screen size. After a little bit of google search, I learnt that I'll need a proper redirect for this to work. There are several steps for using your custom subdomain (www.sezinkarli.com in my case) for your github page:


  1. Add a file named "CNAME" to your root in your github page. Its content must be your subdomain url. "www.sezinkarli.com" in my case.
  2. Define a subdomain for your domain. www.sezinkarli.com in my case.
  3. Configure a CNAME in your subdomain's DNS and point it to your github url (sezinkarli.github.io in my case).
Let me show you these settings ((2) and (3)) for my domain company.

First create s subdomain.

Choose a prefix for your subdomain.

Click on your newly created subdomain.



Edit your subdomains DNS settings.

Choose to add a CNAME and put your github pages url as alias.

4 comments:

  1. Thanks for the tutorial. I followed the instructions but my site keeps redirecting to 1and1 default page. Did you have to configure destination for the main domain?

    ReplyDelete
    Replies
    1. Your main domain must have a frame redirect to your hosting url.
      In my case, sezinkarli.com is redirected to sezinkarli.github.io. Can you try it?

      Delete
  2. Thank you for the article!

    ReplyDelete