Jekyll 如何使用github页面从pdf文件重定向?

Jekyll 如何使用github页面从pdf文件重定向?,jekyll,github-pages,Jekyll,Github Pages,我正在尝试从一个pdf文件重定向到另一个pdf文件。例如: https://my-site.com/the-first-file.pdf 应该重定向到 https://my-site.com/the-second-file.pdf 我查看了重定向,但我无法将元数据添加到pdf文件中 感谢您的帮助 我找到了一个方法。删除-first-file.pdf并创建一个名为-first-file.pdf.html的文件,其内容如下: <script type="text/javascript"&g

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

https://my-site.com/the-first-file.pdf
应该重定向到

https://my-site.com/the-second-file.pdf
我查看了重定向,但我无法将元数据添加到pdf文件中


感谢您的帮助

我找到了一个方法。删除-first-file.pdf并创建一个名为-first-file.pdf.html的文件,其内容如下:

<script type="text/javascript">
 document.location = "/the-second-file.pdf"
</script>

document.location=“/the second file.pdf”
另一种实现这一点的方法(IMO稍微好一点)是模仿
jekyll redirect
所做的,使用
meta-http equiv=“refresh”
标记要求浏览器重定向用户,这不需要javascript

i、 e.您将删除
第一个文件.pdf
,并创建一个名为
第一个文件.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>

重定向。。。
重定向。。。
位置=”https://my-site.com/the-second-file.pdf"
更好的是,您可以利用Jekyll正在生成此文件,并使用站点变量基于配置设置构建URL(当然,您也可以在javascript版本中这样做):

---
---
重定向。。。
{%assign redirect_url=“/the second file.pdf”| prepend:site.baseurl | prepend:site.url%}
重定向。。。
location=“{redirect_url}}”
---
---
<!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>