2017-12-18 315 views
1

我正在构建一个Jekyll站点,并希望在帖子显示页面上显示feature-imgs。我以为自己的Front方向正确,文件路径正确,但由于某种原因,图像仍然不显示。未显示帖子的功能图片Jekyll

前面的问题

--- 
layout: post 
title: My Coding Journey 
feature-img: "/img/journey.png" 
--- 

我的图片名为IMG项目根文件夹中。

邮政布局:

--- 
layout: post-header 
--- 
<article {% if page.feature-img %} class="feature-image"{% endif %}> 
    <section class="post-content">{{ content }}</section> 
</article> 

<!-- Disqus --> 
{% if site.theme_settings.disqus_shortname %} 
<div class="comments"> 
    {% include disqus.html %} 
</div> 
{% endif %} 

任何想法,为什么特征图像不工作。

+0

这是否解决您的问题'功能IMG: “./img/journey.png”'?我在图像路径前添加了一段时间。 – Ivan86

+0

不,不过,谢谢。 – Joseph

+0

尝试像这样'feature-img:“./../ img/journey.png”'或这个'feature-img:“./../../ img/journey.png”' – Ivan86

回答

2

您需要一个img标记才能呈现图像。

--- 
layout: post 
title: My Coding Journey 
feature-img: "/img/journey.png" 
--- 

,并在布局...

<article> 
    {% if page.feature-img %} 
    <img class="feature-image" src={{ page.feature-img }} alt="Feature Image"/> 
    {% endif %} 
    <section class="post-content">{{ content }}</section> 
</article> 
+0

来自Jekyll https://jekyllrb.com/docs/frontmatter/ – Joseph

+0

他们在哪里提到你可以使用'-'作为变量的分隔符? – ashmaroli

+0

我继续进行调整。仍然没有变化。我误解了你的建议。谢谢你。 – Joseph