TransWikia.com

Redirect existing github pages site to custom domain without breaking links

Webmasters Asked by djhworld on November 3, 2021

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

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

Answered by djhworld on November 3, 2021

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.

Answered by Chad Dupuis on November 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP