I have my blog hosted at https://example.github.io and it's been around for a while - and search engines etc. have indexed the pages.

I want to keep hosting the site on github pages (for now) but I want the move the site behind a custom domain.

I know you can setup a CNAME for custom domains on github pages - however it looks like once you do that, github will stop serving the contents from https://example.github.io and just issue a 404 instead, with no opportunity to issue a redirect, so any existing links to the blog will be broken.

Is there any clean way of resolving this?

2 Answers 2


I have my personal blog hosted at gitlab with a custom domain and it is available at both domains after I created the custom domain. I thought it would redirect and perhaps there is a way to do that, but it seems to simply appear at both.

There may be some type of fix for that by now, but there is an old forum post discussing javascript solutions to this (go all the way to the bottom) https://gitlab.com/gitlab-org/gitlab/-/issues/302 . I haven't tried any of these, but that seems sensible enought to me.

  • GitHub and GitLab are not the same thing though
    – wb9688
    Jul 19, 2020 at 21:08
  • 1
    I did misread it, but the issue appears to be the same on both gitlab and github and the solution would be platform agnostic either way... Here's another discussion regarding github specifically stackoverflow.com/questions/30167113/… that has some other options.
    – ChadD
    Jul 20, 2020 at 11:55

For reference I followed the guide https://stackoverflow.com/questions/30167113/redirect-github-pages-to-custom-domain @chad-dupuis suggested.

This meant adding rel=canonical link tags and meta refresh tags (with 5 second grace period) to the github pages version of my site, changing any links to articles to the new URL, along with adding a notice at the top to say the site had moved and will no longer be updated.

It will have to do, not ideal but a good enough compromise

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.