ruby-on-rails - Github 页面上的图像显示错误 - 使用 Jekyll
问题描述
我想使用 Jekyll 托管一个带有 Github 页面的简单博客站点。在帖子中,我想显示图像。为此,我在项目目录的根目录中的文件夹image.html
内添加了一个文件。_includes
我在 image.html 文件中构建了一个 HTML 结构,如下所示:
<figure class="image" style="display: flex; flex-direction: column; align-items: center; justify-content: space-between">
<img src="https://raw.githubusercontent.com/Ritobrato{{include.baseurl}}/gh-pages/_posts" alt="{{ include.description }}">
<div style="padding-top: 10px"></div>
<figcaption>{{ include.description }}</figcaption></figure>
接下来,我_posts
在根目录中为帖子添加了一个新的降价文件。我正在尝试在 .md 发布文件中包含一个图像,如下所示:
{% include image.html url="/images/trek1.jpg" description="This is a trek image" %}
但是,在提交和代码推送到 GitHub 存储库后,GitHub 页面无法显示图像。 单击此处查看图像显示错误。链接到我在 Github repo 上的代码:- https://github.com/Ritobrato/testBlog
在阅读了关于 stackoverflow 的所有类似问题后,这似乎是一个文件链接问题。请帮忙!谢谢
解决方案
标签上的src
属性img
看起来有问题(不指向图像或使用include.url
):
src="https://raw.githubusercontent.com/Ritobrato{{include.baseurl}}/gh-pages/_posts"
我不能确定你想把它指向哪里,但由于这是一个 Jekyll 站点并且你正在传递url
给你的包含,我会说它应该是:
src="{{ site.baseurl }}{{ include.url }}"
或者,如果您不需要使用figure
元素,您可以在 Markdown 文件中添加图像,而不是使用包含:
![This is a trek image]({{ site.baseurl }}/images/trek1.jpg)
推荐阅读
- c - 如何使用 c++ 在 linux shell 中查看当前路径?
- authentication - 将 6.4 eap 迁移到 7.2 eap 时,Jboss Authentication principalsQuery 不起作用
- sql - 如何使用不相等的列和行连接 2 个 SQL 查询
- vba - 取平方根时无效的过程调用或参数(0.5 次方)
- jquery - BootStrap 模态弹出窗口未使用 JQuery 打开
- google-sheets - 如何根据过滤值在另一个 Google 工作表中执行 VLOOKUP?
- php - Laravel Rate Limiting,带有消息和验证后的剩余时间
- c++ - 使用帧缓冲区时出现闪烁区域
- php - php explode is hitting maximum size
- git - Git纠正分支和工作树不匹配