jekyll - 使用 jekyll 链接到 Assets 中的文件在 github 项目页面中不起作用

标签 jekyll assets github-pages

我正在使用 jekyll 设置一个 github 项目页面博客,但指向我的 assets 文件的链接无法正常工作。我看过其他几个有类似问题的帖子,但似乎没有一个适用于我的情况。在标记为重复之前,请检查我是否还没有尝试过其他问题中建议的解决方案。

尝试向我的帖子添加图片时,图片不显示。当我尝试链接到 pdf 以供下载时,我得到一个死链接(如 http://nikosdaniilidis/github.io/assets/all-pdf/Daniilidis2014-surface-noise.pdf)

我尝试了以下配置:

案例0

_config.yml

    baseurl: "/projectname"`
    url: "http://username/github.io/projectname"

_posts/some-post

    ![image here]({{ site.url }}/assets/path/to/image.png)
    [pdf here]({{ site.url }}/assets/path/to/some.pdf)

生成的链接路径(不工作):

    http://nikosdaniilidis/github.io/altblog/assets/all-pdf/Daniilidis2014-surface-noise.pdf

案例一

_config.yml

    baseurl: "/projectname"`
    url: "http://username/github.io"

_posts/some-post

    ![image here]({{ site.baseurl }}/assets/path/to/image.png)
    [pdf here]({{ site.baseurl }}/assets/path/to/some.pdf)

生成的链接路径(不工作):

    http://nikosdaniilidis/github.io/assets/all-pdf/Daniilidis2014-surface-noise.pdf

案例2

_config.yml

    baseurl: "/projectname"`
    url: "http://username/github.io"

_posts/some-post

    ![image here]({{ site.baseurl }}{{post.url}}/assets/path/to/image.png)
    [pdf here]({{ site.baseurl }}{{post.url}}/assets/path/to/some.pdf)

生成的链接路径(不工作):

    http://nikosdaniilidis/github.io/assets/all-pdf/Daniilidis2014-surface-noise.pdf

我的想法已经用完了,非常感谢您的帮助!这是 repo , 这是结果 page (查看 Test links and other asset material 帖子,当前配置了上述最后一种情况)。

谢谢

最佳答案

Github 页面用户存储库 url 模式是 username.github.io 而不是 username/github.io

尝试:

url: http://nikosdaniilidis.github.io
baseurl: /altblog

关于jekyll - 使用 jekyll 链接到 Assets 中的文件在 github 项目页面中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26393333/

相关文章:

css - 修改 Jekyll 中 gist 模板的样式

android - 想从 android 中的 Assets 文件夹中播放 mp4 视频

css - SASS:背景图片 url 和 rails Controller 变量

ruby - 为 github PROJECT 页面配置 Jekyll

github-pages - github 页面的自定义 "username",但不是自定义域

random - Jekyll,液体,随机数

ruby - 尝试使用 jekyll 时如何解决此捆绑更新错误?

android - 构建android apk时如何将参数传递给aapt?

html - 初学者 : CSS and HTML working in Atom but not in GitHub

html - 无法使用 Jekyll 和 github 页面设置图标