Skip to content

Commit

Permalink
Use custom redirect template in jekyll-redirect-from plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
yasulab committed Jan 27, 2025
1 parent 2970335 commit 72ac214
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/_layouts/redirect.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% include head.html %}
<body>
<div class="">
{% include menu.html %}
{{ content }}
{% include footer.html %}
</div>
</body>
</html>
<script type="text/javascript">
function getBrowserLanguage() {
try {
return (navigator.browserLanguage || navigator.language || navigator.userLanguage).substr(0,2)
}
catch(e) {
return undefined;
}
}
// Redirect to the given redirect.to URL. If failed, redirect to the landing page upon browser language.
// https://github.com/jekyll/jekyll-redirect-from#customizing-the-redirect-template
if ("{{ page.redirect.to }}" != ""){
window.location.replace("{{ page.redirect.to }}" + window.location.hash + window.location.search);
}
else if (getBrowserLanguage().indexOf("ja") != -1) {
window.location.replace("/ja");
}
else {
window.location.replace("/en");
}
</script>

0 comments on commit 72ac214

Please sign in to comment.