Skip to content

What's the proper way to move website to a new address?

patarapolw profile image Pacharapol Withayasakpunt twitter logo github logo ・1 min read  

Say, you have initially deploy the website on GitHub Pages, but you want to move to Netlify or Heroku.

Perhaps, totally destroy the old website, and create 404.html for GitHub Pages (or redirect rules with 301 for other websites), filled with one-liner...

<meta http-equiv="refresh" content="0; URL=''" />


Of course, a more sophisticated way would be to use JavaScript with location.replace.

This is my said website, BTW --

twitter logo DISCUSS (17)
markdown guide

If there is a way that you can keep the GitHub Pages for now, then you can set the canonical url of the page to the new website. Google won't punish you (as much) for it. I don't know if this would help in your case, but it might safe your SEO.


Not sure if it helps, but my _config.yml is now.

  - jekyll-redirect-from

I think that if I don't use Jekyll, I cannot get 301...

Not sure if I can use rel=canonical in Jekyll Markdown...


You should be able to, if you can edit any of the elements within

then you can add it. I'm using Jekyll as well and I'm able to do it. What's the link to your repo? I can have a look tomorrow and create a pull request if it's possible.

I'm not sure if it helps. Normally, Google shows the higher domain rank site even the canonicals are set. (Try publishing a post on your blog and DEV on the same day. DEV post will appear even you add canonical).

The recommended way is using the domain migrate tool in the Google search console. However, you cannot do that because it's on


Javascript to change an URL is useless, and would probably cause issues with indexing.

The best way is, indeed, to use a 301 return code.


Can't do that with GitHub Pages BTW. It just has to be either 200 (found a file) or 404.html.


I cannot be really sure about that, so I create both and with the same contents, just in case.

redirect_to: ""

And of course,

  - jekyll-redirect-from

How do I ensure that the code is really 301?

Once deployed, with your browser's network tab open, go to your website and see if you're redirected.

Not working for non-root. It still says 404. (Although it does redirect, and says 301 later.)



Hey! I got this idea.

Github allows you to set custom domain right? (Tutorial)

Add a custom domain first. Then, your Github will automatically redirect your traffic to custom domain (I think).

After that, set up Google search console and add your domain.

After that, you can migrate to whatever host you need. You don't have to redirect because the domain is the same.

What do you think?


Not sure if I understand, but every steps, like pointing domain to GitHub seems to take time...


Of course, a more sophisticated way would be to use JavaScript with location.replace.



As this is posted under #help, some additional context or motivation might be useful.

  1. webserver and dns configuration: If you have a new domain, change the old domain's DNS and create a CNAME to your new domain and use http redirection to the new domain if the server name is the old server name
  2. webserver configuration: If the dns didn't change (only the path to the file) or you can't change it, configure the web server to redirect to the new url with http code.
  3. If you don't have access to the webserver, use http meta header like in the post, and/or/rather give a link for the user that he goes to the new address. You can also add dns prefetch meta header to the html, that will speed up the redirection.
  4. JavavScript has nothing to do with it.
Classic DEV Post from Jul 26 '19

🎩 JavaScript Enhanced Scss mixins! 🎩 concepts explained

In the next post we are going to explore CSS @apply to supercharge what we talk about here....

Pacharapol Withayasakpunt profile image
Currently interested in TypeScript, Vue, Kotlin and Python. Looking forward to learning ML, though.