From ae0c1a62cf7fd7ac4409cc4972db637019dd3d6d Mon Sep 17 00:00:00 2001 From: Andrew Boyer Date: Sun, 4 Feb 2024 15:27:10 -0500 Subject: [PATCH] improved redirect mapping (#2157) In reference to issue: https://github.com/alshedivat/al-folio/discussions/1818 Redirect cases were only happening on the surface level, essentially just affecting the links on [blog index](https://alshedivat.github.io/al-folio/blog/page/4/index.htm) and [year tag](https://alshedivat.github.io/al-folio/blog/2022/). However, from the actual [site](https://alshedivat.github.io/al-folio/blog/2022/redirect/), it would automatically redirect to the `base_url` rather than the actual `redirect`. In my update, if `redirect: true`, like it is in `404.md`, redirect behavior is the same, redirecting to the `base_url`. If it is an external link, then the redirect is external. And finally if it is an internal redirect, like it is in https://alshedivat.github.io/al-folio/blog/2022/redirect/, than the redirect is `page.redirect | relative_url` --- _layouts/default.liquid | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/_layouts/default.liquid b/_layouts/default.liquid index 6809a73..1c3584e 100644 --- a/_layouts/default.liquid +++ b/_layouts/default.liquid @@ -3,7 +3,14 @@ {% if page.redirect %} - + {% if page.redirect == true %} + {% assign redirect = site.baseurl | append: '/' %} + {% elsif page.redirect contains '://' %} + {% assign redirect = page.redirect %} + {% else %} + {% assign redirect = page.redirect | relative_url %} + {% endif %} + {% endif %} {% include head.liquid %}