Ruby 在include语句jekyll中使用页面属性
我有一个jekyll页面,其中有两个文件夹:Ruby 在include语句jekyll中使用页面属性,ruby,jekyll,Ruby,Jekyll,我有一个jekyll页面,其中有两个文件夹:products\u products/product\u name 我有一个产品页面md文件,其中包含: --- title: product_title subtitle: subtilte layout: product description: long description product_icon: product_image_path --- 这个简单的布局: --- layout: default --- <!-- Main
products
\u products/product\u name
我有一个产品页面md文件,其中包含:
---
title: product_title
subtitle: subtilte
layout: product
description: long description
product_icon: product_image_path
---
这个简单的布局:
---
layout: default
---
<!-- Main -->
<div id="main">
<div id="content" class="container">
<header id="product_header">
<div class="half_left center">
<img id="product_icon" src="/assets/{{ page.product_icon }}" alt="">
<h2 id="product_title">{{ page.title }}</h2>
<h3 id="product_subtitle">{{page.subtitle}}</h3>
</div>
<div class="half_right center">
{% markdown _products/page.title/short.md %}
</div>
<div class="clear"></div>
</header>
{{content}}
</div>
</div>
有人能告诉我如何在{%markdown\u products/page.title/short.md%}
中捕获page.title吗?我得到了这个错误:液体异常:没有这样的文件或目录@rb\u sysopen-/home/tools/git/pagename.github.io//u products/page.title/short in\u layouts/product.html
我在jekyll中找到了一个不同的内置解决方案,因此我不需要一个插件
假设您在pathmarkdown\u文件中有markdown文件john.md
,那么我们可以执行以下操作:
{% capture john %}
{% include_relative markdown_files/john.md %}
{% endcapture %}
然后我们想在哪里输入现在在john
中捕获的john.md
文本,我们可以把这个{{john | markdownify}}
这不是一个光滑的,不是一个班轮,但它的工作。根据您的设置,您可以使用include
而不是include\u relative
希望它能帮助其他人,感谢Jekyll IRC社区帮助我找到解决方案
{% capture john %}
{% include_relative markdown_files/john.md %}
{% endcapture %}