Jekyll redirect link

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

  • it is OK to use the wrong HTTP response code (200 OK instead of 301 Moved Permanently),
  • you are hosted in GitHub pages,
  • you want to rely on the build-in features, and
  • you do not want to use GitHub workflows for building and pushing to gh-pages then

you can do following:

  1. 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>
    
  2. 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.