Jekyll 重定向 link
Jekyll redirect link
我将我的网站 http://www.phonations.com 移动到 Jekyll/GitHub 页。
在那之前,我知道如何将我网站上的一些 url 重定向到外部网站。现在该怎么做?
例如,我想要 http://www.phonations.com/tmwtga to redirect to https://www.dropbox.com/s/tw1b0kvoc75c7lx/tmwtga.zip?dl=0 或其他一些 url(使用 git lfs)。
虽然插件 "jekyll-redirect-from" 允许将路径重定向到页面,但它似乎不允许将路径重定向到另一种资源。
该插件确实允许重定向到外部 URL。要重定向您的示例 URL,请创建一个名为 tmwtga.html
的文件并添加以下内容:
---
permalink: /tmwtga
redirect_to:
- http://www.example.com
---
假设您的服务器支持无扩展名 URLs(在本例中 GitHub Pages 支持)。你可能不需要 permalink
,但我把它放在那里以防你在 _config.yml
.
中设置了默认值
来源:https://github.com/jekyll/jekyll-redirect-from#redirect-to
万一
- 可以使用错误的 HTTP 响应代码(
200 OK
而不是 301 Moved Permanently
),
- 您在 GitHub 个页面中托管,
- 您想依赖内置功能,并且
- 您不想使用 GitHub 工作流来构建和推送到
gh-pages
然后
您可以执行以下操作:
创建文件_layouts/redirect.html
:
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="refresh" content="1;url={{ page.redirect }}"/>
<link rel="canonical" href="{{ page.redirect }}"/>
<script type="text/javascript">
window.location.href = "{{ page.redirect }}"
</script>
<title>Page Redirection</title>
</head>
<body>
If you are not redirected automatically, follow <a href='{{ page.redirect }}'>this link</a>.
</body>
</html>
对于每个要重定向的页面,请使用以下内容:
---
redirect: https://www.example.org
layout: redirect
---
HTML 代码是 tutorial by W3C 提供的 HTML 代码的扩展。
我将我的网站 http://www.phonations.com 移动到 Jekyll/GitHub 页。
在那之前,我知道如何将我网站上的一些 url 重定向到外部网站。现在该怎么做?
例如,我想要 http://www.phonations.com/tmwtga to redirect to https://www.dropbox.com/s/tw1b0kvoc75c7lx/tmwtga.zip?dl=0 或其他一些 url(使用 git lfs)。
虽然插件 "jekyll-redirect-from" 允许将路径重定向到页面,但它似乎不允许将路径重定向到另一种资源。
该插件确实允许重定向到外部 URL。要重定向您的示例 URL,请创建一个名为 tmwtga.html
的文件并添加以下内容:
---
permalink: /tmwtga
redirect_to:
- http://www.example.com
---
假设您的服务器支持无扩展名 URLs(在本例中 GitHub Pages 支持)。你可能不需要 permalink
,但我把它放在那里以防你在 _config.yml
.
来源:https://github.com/jekyll/jekyll-redirect-from#redirect-to
万一
- 可以使用错误的 HTTP 响应代码(
200 OK
而不是301 Moved Permanently
), - 您在 GitHub 个页面中托管,
- 您想依赖内置功能,并且
- 您不想使用 GitHub 工作流来构建和推送到
gh-pages
然后
您可以执行以下操作:
创建文件
_layouts/redirect.html
:<html> <head> <meta charset="utf-8"/> <meta http-equiv="refresh" content="1;url={{ page.redirect }}"/> <link rel="canonical" href="{{ page.redirect }}"/> <script type="text/javascript"> window.location.href = "{{ page.redirect }}" </script> <title>Page Redirection</title> </head> <body> If you are not redirected automatically, follow <a href='{{ page.redirect }}'>this link</a>. </body> </html>
对于每个要重定向的页面,请使用以下内容:
--- redirect: https://www.example.org layout: redirect ---
HTML 代码是 tutorial by W3C 提供的 HTML 代码的扩展。