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'" />
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 (14)
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.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.github.com/patarapolw/blog/tree/gh...
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
I cannot be really sure about that, so I create both
index.md
and404.md
with the same contents, just in case.And of course,
How do I ensure that the code is really 301?
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...
Can't do that with GitHub Pages BTW. It just has to be either 200 (found a file) or
404.html
.Not working for non-root. It still says 404. (Although it does redirect, and says 301 later.)
See patarapolw.github.io/blog/post/ele...
Pretty Cool!
Some comments may only be visible to logged-in visitors. Sign in to view all comments.