从构建和导航中删除页面?
Removing pages from build and nav?
我需要能够从构建中排除某些文件。我知道我可以在配置文件中执行此操作。
我还需要一种方法来关闭导航中的网站部分。
所以我考虑在数据文件中设置一个标志,如果它是错误的,则不要在导航部分包含 link。
但是我怎样才能使用相同的标志来阻止构建该部分?
或者在配置中指定并在导航中检查这个标志是否更容易?
对我来说似乎是配置问题。我会把它放在配置中,让你的 include 和 nav 检查配置值。
要从构建中排除文件,请将此行添加到您的 _config.yml
:
keep_files: [folder, "file.ext"]
Jekyll 将保留 folder
和 file.ext
,并将包含在构建中。
或
exclude: ["file.md", "otherfile.html"]
这两个文件都不会包含在您由 Jekyll 构建的站点中。
这里:
I also need a way to turn off a section of the website in the nav.
我不确定你的意思,但我想你可以用 if
语句来做到这一点:
在 post 或页首内容中,添加一个变量指示要排除的部分:
---
# your front matter settings
foo: bar # variable and value
---
然后,在您的模板中添加:
{% if page.foo %}
<div>this will display</div>
{% endif %}
或
{% if page.foo %}
<div>this will display</div>
{% else %}
<p>this will display when the above doesn't</p>
{% endif %}
希望对您有所帮助! :)
我需要能够从构建中排除某些文件。我知道我可以在配置文件中执行此操作。
我还需要一种方法来关闭导航中的网站部分。
所以我考虑在数据文件中设置一个标志,如果它是错误的,则不要在导航部分包含 link。
但是我怎样才能使用相同的标志来阻止构建该部分?
或者在配置中指定并在导航中检查这个标志是否更容易?
对我来说似乎是配置问题。我会把它放在配置中,让你的 include 和 nav 检查配置值。
要从构建中排除文件,请将此行添加到您的 _config.yml
:
keep_files: [folder, "file.ext"]
Jekyll 将保留 folder
和 file.ext
,并将包含在构建中。
或
exclude: ["file.md", "otherfile.html"]
这两个文件都不会包含在您由 Jekyll 构建的站点中。
这里:
I also need a way to turn off a section of the website in the nav.
我不确定你的意思,但我想你可以用 if
语句来做到这一点:
在 post 或页首内容中,添加一个变量指示要排除的部分:
---
# your front matter settings
foo: bar # variable and value
---
然后,在您的模板中添加:
{% if page.foo %}
<div>this will display</div>
{% endif %}
或
{% if page.foo %}
<div>this will display</div>
{% else %}
<p>this will display when the above doesn't</p>
{% endif %}
希望对您有所帮助! :)