本文介绍了Jekyll:在_includes之外的目录中包含一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Jekyll网站上有一个名为 / patterns 的目录,其结构通常如下所示:

I have an directory called /patterns in my Jekyll site, whose structure generally looks generally like this:


_includes
_layouts
_site
/ patterns
index.html

我需要在 _includes 之外的 / patterns 目录中保留一个数字原因,但主要是因为我需要将 / patterns 中的文件拉到iframe中以显示在模式库中。)

I need to keep the /patterns directory outside _includes for a number of reasons, but mostly because I need to pull the files in /patterns into an iframe to display in a pattern library).

我想在我的Jekyll页面中包含来自 / patterns 的文件,但使用 {%include /patterns/file.html% }无效,因为它指向 _includes 文件夹。如何从不是 _includes`的目录中包含文件?

I'd like to include files from /patterns in my Jekyll pages, but using {% include /patterns/file.html %} doesn't work as it points to the_includesfolder. How would I go about including a file from a directory that isn't_includes`?

推荐答案

您可以在 _config.yml include 标记与 includes_dir 一起使用的目录/ code>。看起来您不能设置多条路径(来源:)。

You can change the directory that the include tag uses with includes_dir in your _config.yml. It doesn't look like you can set multiple paths (source: https://jekyllrb.com/docs/configuration/).

在任何情况下, _includes 中的文件都不会在输出中结束。您可以将特定于模式的包含分成 _includes / patterns / ,但对您的实时网站产生任何影响的唯一方法就是包含这些文件的位置。

In any case, the files in _includes don't end up in your output. You could separate pattern-specific includes into _includes/patterns/, but the only thing that'd have any effect on your live site would be where those files were included.

这篇关于Jekyll:在_includes之外的目录中包含一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 15:33