jekyll - Octopress HTML 包含参数

标签 jekyll octopress

我想在博客文章中包含 HTML 片段,并将代码放在一个位置。在仔细研究了该框架之后,我已经能够让它发挥作用:

source
  _includes
    custom
      foo.html

{% include custom/foo.html %}

我的问题:有没有办法可以将参数传递给 foo.html?我只是想传入一些字符串并以格式化的方式输出它们,但无法弄清楚我缺少什么。

感谢您的宝贵时间。

最佳答案

你不能。但是您可以使用其他方式(例如主题所做的那样)来执行此操作。

首先,在custom/foo.html中设置你想要的格式化样式,例如我在source/_includes/custom/footer中添加一个customfooter。 html:

<p>
  Copyright &copy; {{ 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/

相关文章:

php - 具有动态组件的静态站点生成器

html - 在 octopress post 中添加一个 anchor

ruby-on-rails - Jekyll 安装失败

html - Jekyll 拒绝 build ,尽管它之前 build 过

jekyll - 如果两个帖子解析为 Jekyll 中的相同永久链接,则构建失败

ruby - 启动服务器时出现 Jekyll 错误

jekyll - 从液体数组中获取下一个和上一个元素

sass - Octopress,更改主题中的样式表

blogs - 如何在 Octorpess/Jekyll 登陆页面上显示最新的博客文章