gpt4 book ai didi

jekyll - 如何使用 github-pages 从 pdf 文件重定向?

转载 作者:行者123 更新时间:2023-12-05 01:46:08 24 4
gpt4 key购买 nike

我正在尝试从一个 pdf 文件重定向到另一个。所以,例如:

https://my-site.com/the-first-file.pdf

应该重定向到

https://my-site.com/the-second-file.pdf

我看了github's documentation关于重定向,但我无法将该元数据添加到 pdf 文件中...

感谢任何帮助!

最佳答案

另一种(IMO 稍微好一点的)方法是模仿 jekyll-redirect 的作用,使用 meta http-equiv="refresh"标记要求浏览器重定向用户,这不需要 javascript。

即您将删除 the-first-file.pdf 并创建一个名为 the-first-file.pdf.html 的文件,其中包含以下内容:

<!DOCTYPE html>
<meta charset="utf-8">
<title>Redirecting...</title>
<link rel="canonical" href="https://my-site.com/the-second-file.pdf">
<meta http-equiv="refresh" content="0; url=https://my-site.com/the-second-file.pdf">
<h1>Redirecting...</h1>
<a href="https://my-site.com/the-second-file.pdf">Click here if you are not redirected.</a>
<script>location="https://my-site.com/the-second-file.pdf"</script>

更好的是,您可以利用 Jekyll 生成此文件的优势,并使用站点变量根据配置设置构建 URL(当然,您也可以在 javascript 版本中这样做):

---
---
<!DOCTYPE html>
<meta charset="utf-8">
<title>Redirecting...</title>
{% assign redirect_url = "/the-second-file.pdf" | prepend: site.baseurl | prepend: site.url %}
<link rel="canonical" href="{{ redirect_url }}">
<meta http-equiv="refresh" content="0; url={{ redirect_url }}">
<h1>Redirecting...</h1>
<a href="{{ redirect_url }}">Click here if you are not redirected.</a>
<script>location="{{ redirect_url }}"</script>

关于jekyll - 如何使用 github-pages 从 pdf 文件重定向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37684319/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com