21

I created a Jekyll-powered blog and am hosting it with GitHub Pages.

Now, I want to set up a subdomain (blog.example.com), but can't make it work.

I have added a CNAME file with the text: blog.example.com. And I have added two A records in my Dreamhost account for the subdomain, both pointing to 204.232.175.78, provided by GitHub.

Any idea about what the missing part is, or if I'm doing something incorrectly?

alejorivera
  • 935
  • 1
  • 10
  • 25

2 Answers2

64

The setup is different for domains like example.com and sub-domains like blog.example.com.

In case of a sub-domain: blog.example.com

  1. Go to Domains | Manage Domains in your webpanel
  2. Locate blog.example.com, click Delete in the Actions column
  3. Wait 10 minutes, and then click the DNS link below example.com
  4. Add a CNAME record:
    • Name = blog
    • Type = CNAME
    • Value = yourusername.github.io. (yes there is a . at the end!)

In case of a domain: example.com

  1. Go to Domains | Manage Domains in your webpanel
  2. Locate example.com, click Edit in the Actions column and switch to DNS only hosting (it's at the bottom)
  3. Go back to Domains | Manage Domains in your webpanel
  4. Click the DNS link below example.com
  5. Add an A record:
    • Name = (blank, nothing)
    • Type = A
    • Value = 185.199.108.153 (GitHub, from this page)
  6. Add a CNAME record:
    • Name = www
    • Type = CNAME
    • Value = yourusername.github.io. (yes there is a . at the end!)

(Yes, you need both the A and CNAME records in this case.)

Btw, the only reason I know this is because I did the same thing last weekend. I was quite lost, but the helpful support guys helped me half way, and I figured out the rest. This procedure works for me, I needed both cases so I tested both.

Michael Whatcott
  • 5,603
  • 6
  • 36
  • 50
janos
  • 120,954
  • 29
  • 226
  • 236
  • Janos, Yes! Thank you, this worked perfectly. I had tried to up vote it but apparently I still can't, and I didn't know I could respond to comments. But anyways, thanks a lot! – alejorivera Dec 19 '13 at 23:29
  • 2
    Is there any way to do both? ie your root url is example.com, which shows example.github.io (you have a repo called example.github.io and your username is example) AND blog.example.com forwards to a project's gh-pages branch (you have a repo called blog that is available at example.github.io/blog). – chandlervdw Mar 11 '14 at 02:45
  • @chandlervdw I think all you have to do (in Dreamhost) is go: Add New Domain / Sub-Domain -> scroll to the bottom -> type the sub-domain and host DNS only -> follow the settings above for setting CNAME – Coffee Cup Jun 27 '14 at 02:43
  • Thanks, just FYI make sure you have any DNS redirects disabled on the domain too. I had a redirect and kept getting an error when trying to add the www CNAME – Justin Garrison Sep 17 '14 at 06:14
  • 4
    Looks like the new IPs are 192.30.252.153 and 192.30.252.154, see [here](https://help.github.com/articles/tips-for-configuring-an-a-record-with-your-dns-provider/) – danvk Oct 23 '14 at 14:18
  • 1
    Is it just me or does GIthub really fail to provide any information about the apex domain case needing the CNAME record as well? Thank you @janos for making this clear – mzrnsh Jan 30 '16 at 07:32
2

Because of the way DNS records are cached across the internet, these sorts of changes can take a few hours to take effect. It looks like the address you provided resolves correctly now.

Brian Willis
  • 22,768
  • 9
  • 46
  • 50