如何在静态网站上创建重定向?

时间:2020-07-22 12:06:46

标签: html redirect jekyll

我在GitHub页面上托管了一个jekyll网站。

我想创建指向其他地方的短链接。例如,example.com/l可以重定向到linkedin.com/example

是否有一种方法可以在静态托管的网站上实现此目标而又不会弄乱我的域名注册商?

3 个答案:

答案 0 :(得分:2)

您可以使用添加到页面<meta>部分的<head>标签。

<meta http-equiv="Refresh" content="0; url='https://your.redirect.here'" />

这将在页面加载时重定向浏览器。

答案 1 :(得分:2)

您可以将jekyll-redirect-fromallows you to specify that a page should be redirected to a different website插件用于Jekyll。

在您的示例中,您将创建一个名为l.md的页面,其首页如下所示:

---
title: My LinkedIn Profile
redirect_to: https://linkedin.com/example
---

答案 2 :(得分:1)

好像您需要在jekyll中为example.com/l创建一个页面。在该页面上,您可以添加带有{p>的script标签

window.location.replace("linkedin.com/example")

simulate an HTTP redirect或尝试从此脚步ObsoleteAwareProduce's method