如何提供文件供下载?

How do I provide files for download?

我写了一个post,想提供一个文件作为附件下载。

到目前为止我有

但是,文件没有被复制到正确的位置。

我有

所以这两个页面都没有给我关于如何提供文件下载的答案。

我不知道应该把静态文件放在目录结构中的什么位置。一旦我知道了,似乎我可以使用像 {{ site.static_files }} 这样的 Liquid,但即便如此我仍然需要指定一个文件名。

这是我的解决方案。我有一个“我的名字”。github.io,我在 myname.github.io 中创建了一个文件夹 /download,在这个 download 文件夹中我上传了我想包含在我的 [=] 中的文件19=]s.

在单个 post 然后我创建了以下代码:

some text and [here is possible to download the file in PDF][1]

[1]:{{ site.url }}/download/file.pdf

您可以将 download.zip 文件放在项目的根目录下,它会被复制到 {{ site.url }}/download.zip。如果您希望它包含在一个文件夹中,您可以创建任何文件夹,例如 download/,并且任何文件都可以通过 {{ site.url }}/download/*.

访问

Every other directory and file except for [the Jekyll files]—such as css and images folders, favicon.ico files, and so forth—will be copied verbatim to the generated site.

来自 the Jekyll Docs