我想在博客文章中包含 HTML 片段,并将代码放在一个位置。在仔细研究了该框架之后,我已经能够让它发挥作用:
source
_includes
custom
foo.html
{% include custom/foo.html %}
我的问题:有没有办法可以将参数传递给 foo.html?我只是想传入一些字符串并以格式化的方式输出它们,但无法弄清楚我缺少什么。
感谢您的宝贵时间。
最佳答案
你不能。但是您可以使用其他方式(例如主题所做的那样)来执行此操作。
首先,在custom/foo.html
中设置你想要的格式化样式,例如我在source/_includes/custom/footer中添加一个
:customfooter
。 html
<p>
Copyright © {{ site.time | date: "%Y" }} - {{ site.author }} -
<span class="credit">Powered by <a href="http://octopress.org">Octopress</a></span>
{{ site:customfooter }}
</p>
然后,在_config.yml
中设置你想要设置的字符串:
url: http://fann.im
customfooter: My custom footer, bala bala.
希望这对您有帮助。
关于jekyll - Octopress HTML 包含参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14949298/