I moved my site http://www.phonations.com to Jekyll/GitHub pages.
Before that, I knew how to redirect some urls on my site to external ones. How to do that now?
For example, I would like http://www.phonations.com/tmwtga to redirect to https://www.dropbox.com/s/tw1b0kvoc75c7lx/tmwtga.zip?dl=0 or some other url (using git lfs).
While the plugin "jekyll-redirect-from" allows redirecting a path to a page, it does not seem to allow redirecting a path to another kind of resource.
JekyllRedirectFrom can be used to setup multiple redirects for a URL on jekyll sites. All you need to do is add the jekyll-redirect-from gem to your jekyll project and add a redirect_from in the YAML front matter of post or a page to specify the older locations from which the current location is mapping to.
To redirect one HTML page to another page, you need to add a <meta> tag inside the <head> section of the old HTML page. The <head> section of an HTML document contains metadata that is useful for the browser, but invisible to users viewing the page.
The redirect is accomplished with a <meta> tag. By setting the http-equiv attribute to refresh and the content attribute to 0; URL=https://example.com/ we will redirect the user to 'https://example.com/'.
That plugin does allow for redirecting to external URLs. To redirect your example URL, create a file called tmwtga.html
and add the following front matter:
---
permalink: /tmwtga
redirect_to:
- http://www.example.com
---
Assumes your server supports extensionless URLs (in this case GitHub Pages does). You might not need the permalink
, but I put it in there in case you have a default set in _config.yml
.
Source: https://github.com/jekyll/jekyll-redirect-from#redirect-to
In case
200 OK
instead of 301 Moved Permanently
),gh-pages
thenyou can do following:
Create file _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>
For each page, you want to redirect from, use following content:
---
redirect: https://www.example.org
layout: redirect
---
The HTML code is an extention to the HTML code provided by a tutorial by W3C.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With