Skip to content

Commit

Permalink
improved redirect mapping (#2157)
Browse files Browse the repository at this point in the history
In reference to issue:
#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`
  • Loading branch information
asboyer authored Feb 4, 2024
1 parent 18f7307 commit ae0c1a6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion _layouts/default.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
<!-- Head -->
<head>
{% if page.redirect %}
<meta http-equiv="refresh" content="3; url={{ site.baseurl }}/">
{% 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 %}
<meta http-equiv="refresh" content="3; url={{ redirect }}">
{% endif %}
{% include head.liquid %}
</head>
Expand Down

0 comments on commit ae0c1a6

Please sign in to comment.