【问题标题】:include_relative post.path jekyllinclude_relative post.path jekyll
【发布时间】:2014-11-21 22:38:00
【问题描述】:

我正在尝试将多个相关帖子放在一个页面上。问题是包含的帖子都是纺织页面,使用了一些 {% highlight %} 标签。当我尝试通过 post.content 包含它们时,它们不会被文本化(例如,我在页面上看到“{% highlight...”)。

我尝试了几种不同的方法:

这永远不会被纺织化:

{% for post in site.tags.my_tag %}
{{ post.content | textilize }}
{% endfor %}

这(基于http://nateeagle.com/2011/08/31/jekyll-not-parsing-includes/)不返回任何内容:

{% for post in site.tags.apidocs %}
{% capture included_post %}
{{% include_relative post.path %}}
{% endcapture %}
{{ included_post | textilize }}
{% endfor %}

有什么想法吗?

布拉德利

【问题讨论】:

  • 为了清楚起见,我的目标是在包含的帖子中执行一些液体标签,这是一个 .textile 文件。包含上述内容的文件也是.textile文件。
  • 我发现的一个问题是 post.path 返回了“_posts/file.textile”,我认为这不是当前文件的正确相对路径。我将 ../ 连接到该路径,但仍然没有骰子。
  • 我注意到如果我直接引用文件名(例如,{% include_relaitve myfile.textile %},它工作得很好。所以我认为我在这里寻找的是如何通过通过变量将文件名添加到 include_relative。

标签: jekyll liquid textile


【解决方案1】:

试试

{% include_relative {{post.path}} %}

【讨论】:

  • 谢谢。这修复了包含。唉,意识到我现在需要删除前面的问题......
  • 万一其他人遇到这个问题,完整的解决方案涉及以下插件:dtsn.me/2013/07/11/remove-front-matter-jekyll-plugin plus(来自大卫的更正):{% for post in site.tags.my_tags %} {%捕获included_post %} {% include_relative {{post.path |替换:'_posts/',''}} %} {% endcapture %} {{ included_post | removefrontmatter }} {% endfor %}
猜你喜欢
  • 2015-04-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-10
  • 2020-05-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多