是否有jekyll {{%include%}}选项



我创建了一个网站,每个页面都有相同的页眉和页脚。现在,如果我想更改页眉或页脚中的任何内容,我需要更改所有的html文件。

有什么简单的方法可以避免这种重复的工作吗?我正在寻找的东西像{{% include header.html %}}在jekyll.

从你的问题看来,你似乎错过了/没有完全理解模板的概念。模板包含header.html和footer.html的include。该页只包含对模板的引用。这是Jekyll防止将include添加到每个页面的重复工作的方法。

理想的页面是一个(索引)。文件标题如下:

---
title: Title of the page
layout: template
---
Lorem ipsum

模板文件名为template.html,位于_layouts文件夹中。它看起来像这样:

{% include header.html %}
{{ content }}
{% include footer.html %}

希望有帮助!

有这样一个方法:

{% include header.html %}

上传header.html到你网站根目录下的_includes文件夹

最新更新