Invalid CNAME record for GitHub Pages

To configure GitHub Pages with a custom domain, I need to create an record with <username>.github.io.. However, this cannot be done for me because myuser name ended with a hyphen. e.g. foobar-.github.io, which failed with the follwoing error:

Content for CNAME record is invalid (Code: 9007)

What possibly can I do to resolve this, without changing my GitHub username?

That won’t be your github.io hostname then. You first need to clarify with Github what your actual hostname is.

Though that cannot be either

Hi @sandro,

Thanks for you reply. Actually you maybe right. This maybe an design issue on the GitHub site.

You can check my GitHub profile here. https://github.com/ee-/

I think they changed the validation rule for the usernames.

Pinging ee-.github.io [185.199.110.153] with 32 bytes of data:
Reply from 185.199.110.153: bytes=32 time=51ms TTL=57
Reply from 185.199.110.153: bytes=32 time=51ms TTL=57
Reply from 185.199.110.153: bytes=32 time=50ms TTL=57
Reply from 185.199.110.153: bytes=32 time=51ms TTL=57

Strange!

Fair enough, that seems to be a glitch on Github’s end. A hostname is not supposed to end with a hyphen, hence you cannot set it up. You could either change the username or set up an A record instead of a CNAME record, however in the latter case you’d need to regularly check if the IP address changed and update it.

Alternatively you could probably set up a CNAME record for a random username, as these seem to resolve to the same address, but that might change too.

You are right!

I added a CNAME record directly to github.io and it does the trick. (Thanks to the CNAME Flattening.)

Cheers!