在 Jekyll 和 GitHub Pages 中重定向旧页面的最佳方法是什么? [英] What is the best approach for redirection of old pages in Jekyll and GitHub Pages?
问题描述
我在 github 页面上有博客 - jekyll
I have blog on github pages - jekyll
解决url策略迁移的最佳方法是什么?
What is the best way to solve url strategy migration?
我发现共同的最佳实践是像这样创建 htaccess
I found the best practice in common is create htaccess like so
Redirect 301 /programovani/2010/04/git-co-to-je-a-co-s-tim/ /2010/04/05/git-co-to-je-a-co-s-tim.html
但它似乎不适用于 Github.我发现的另一个解决方案是创建 rake 任务,它将生成重定向页面.但是因为是html,所以不能发送301
头部,所以SE爬虫不会把它识别为重定向.
But it does not seems to work with Github. Another solution i found is create rake task, which will generate redirection pages. But since it's an html, it's not able to send 301
head, so SE crawlers will not recognize it as an redirection.
推荐答案
最好的解决方案是同时使用 <meta http-equiv="refresh"
和 <link rel=规范" href=
The best solution is to use both <meta http-equiv="refresh"
and <link rel="canonical" href=
效果很好,Google Bot 在新链接下重新索引了我的整个网站,而不会丢失任何位置.此外,用户会立即被重定向到新帖子.
It works very well, Google Bot reindexed my entire website under new links without losing positions. Also the users are redirected to the new posts right away.
<meta http-equiv="refresh" content="0; url=http://konradpodgorski.com/blog/2013/10/21/how-i-migrated-my-blog-from-wordpress-to-octopress/">
<link rel="canonical" href="http://konradpodgorski.com/blog/2013/10/21/how-i-migrated-my-blog-from-wordpress-to-octopress/" />
使用 <meta http-equiv="refresh"
会将每个访问者重定向到新帖子.至于 Google Bot,它将 <link rel="canonical" href=
视为 301 重定向,其效果是您的页面被重新索引,这正是您想要的.
Using <meta http-equiv="refresh"
will redirect each visitor to the new post.
As for Google Bot, it treats <link rel="canonical" href=
as 301 redirect, the effect is that you get your pages reindexed and that is what you want.
我在这里描述了我如何将我的博客从 Wordpress 迁移到 Octopress 的整个过程.http://konradpodgorski.com/blog/2013/10/21/how-i-migrated-my-blog-from-wordpress-to-octopress/#redirect-301-on-github-pages
I described whole process how I moved my blog from Wordpress to Octopress here. http://konradpodgorski.com/blog/2013/10/21/how-i-migrated-my-blog-from-wordpress-to-octopress/#redirect-301-on-github-pages
这篇关于在 Jekyll 和 GitHub Pages 中重定向旧页面的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!