使用 Jekyll,在不破坏旧 link 的情况下修复错误输入的日期
With Jekyll, fix mistyped date without breaking old link
我正在为我的博客使用 Jekyll。我添加了一个新博客 post here,其中将 URL 名称错误输入为 /2019/09/22/automation-patents-paper/
(因此年份错误)。
这搞砸了 post 顶部的日期,如果我将 post 的日期保留在 2019 年,那么它将保留在我的 list of posts 顶部两年...
但我已经在社交媒体上分享了此 URL 下的博客,并希望人们能够继续通过 link 访问 post。我已经通过电子邮件将 link 发送给一些人,我真的很想点击它而不是进入某些 404 页面。
如果我使用正确的名称重新发布 post,是否有某种方法可以将旧的 URL 重新路由到新的 URL?
使用插件将旧的 post url 重定向到新的 post,并用正确的 url.
修复 post
使用 jekyll-redirect-from 添加到 Gemfile:
gem 'jekyll-redirect-from'
运行bundle
或gem install jekyll-redirect-from
,然后加上_config.yml
:
gems:
- jekyll-redirect-from
现在在新的post中添加旧的url:
redirect_from:
- /2019/09/22/automation-patents-paper/
将生成:/2019/09/22/automation-patents-paper/index.html
指向新的 post。
我正在为我的博客使用 Jekyll。我添加了一个新博客 post here,其中将 URL 名称错误输入为 /2019/09/22/automation-patents-paper/
(因此年份错误)。
这搞砸了 post 顶部的日期,如果我将 post 的日期保留在 2019 年,那么它将保留在我的 list of posts 顶部两年...
但我已经在社交媒体上分享了此 URL 下的博客,并希望人们能够继续通过 link 访问 post。我已经通过电子邮件将 link 发送给一些人,我真的很想点击它而不是进入某些 404 页面。
如果我使用正确的名称重新发布 post,是否有某种方法可以将旧的 URL 重新路由到新的 URL?
使用插件将旧的 post url 重定向到新的 post,并用正确的 url.
修复 post使用 jekyll-redirect-from 添加到 Gemfile:
gem 'jekyll-redirect-from'
运行bundle
或gem install jekyll-redirect-from
,然后加上_config.yml
:
gems:
- jekyll-redirect-from
现在在新的post中添加旧的url:
redirect_from:
- /2019/09/22/automation-patents-paper/
将生成:/2019/09/22/automation-patents-paper/index.html
指向新的 post。