DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

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

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='http://new-website.com'" />
Enter fullscreen mode Exit fullscreen mode

See https://css-tricks.com/redirect-web-page/

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

This is my said website, BTW -- https://patarapolw.github.io/blog

Top comments (17)

Collapse
 
roelofjanelsinga profile image
Roelof Jan Elsinga

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.

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited on

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

gems:
  - jekyll-redirect-from
url: https://polvcode.dev

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

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

Collapse
 
roelofjanelsinga profile image
Roelof Jan Elsinga

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.
Thread Thread
 
patarapolw profile image
Pacharapol Withayasakpunt
Collapse
 
supunkavinda profile image
Supun Kavinda

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 Guthub.io

 
patarapolw profile image
Pacharapol Withayasakpunt

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

---
redirect_to: "https://polvcode.dev"
---

And of course,

gems:
  - jekyll-redirect-from

How do I ensure that the code is really 301?

Collapse
 
supunkavinda profile image
Supun Kavinda • Edited on

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?

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

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

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

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

 
patarapolw profile image
Pacharapol Withayasakpunt • Edited on

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

See patarapolw.github.io/blog/post/ele...

Collapse
 
saxode profile image
Saxode • Edited on

Pretty Cool!

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

πŸ‘‹ Hey, my name is Noah and I’m the one who set up this ad. My job is to get you to join DEV, so if you fancy doing me a favor, I’d love for you to create an account.

If you found DEV from searching around, here are a couple of our most popular articles on DEV: