我认为设置relative_directory (Jekyll Collection Docs) (github PR)属性可以帮助我在不影响所需输出的情况下保持文件井井有条,但它似乎被忽略/不用于生成文件。我不希望我的收藏是在根目录下,因为我觉得它混淆有邻近〜10集合文件夹_assets,_data,_includes,_layouts,和其他人。
欢迎修复或替代解决方案,只要输出相同,并且我的页面在他们自己的目录中,而无需permalink在每个页面上都放置前端。
_config.yaml
collections:
root:
relative_directory: '_pages/root'
output: true
permalink: /:path.html
root-worthy:
relative_directory: '_pages/root-worthy'
output: true
permalink: /:path.html
docs:
relative_directory: '_pages/docs'
output: true
permalink: /docs/:path.html
Run Code Online (Sandbox Code Playgroud)
目录结构:
??? ...
??? _layouts
??? _pages
? ??? root
? ? ??? about.html
? ? ??? contact.html
? ??? root_worthy
? ? ??? quickstart.html
? ? ??? seo-worthy-page.html
? ??? docs
? ??? errors.html
? ??? api.html
??? _posts
??? index.html
Run Code Online (Sandbox Code Playgroud)
期望的输出:
??? ...
??? _site
? ??? about.html
? ??? contact.html
? ??? quickstart.html
? ??? seo-worthy-page.html
? ??? docs
? ??? errors.html
? ??? api.html
??? ...
Run Code Online (Sandbox Code Playgroud)
看来你提到的PR还没有合并。
对于 3.1.6 和接下来的 3.2,jekyll 代码仍然是:
@relative_directory ||= "_#{label}"
Run Code Online (Sandbox Code Playgroud)
但请求者制作了一个如下所示的插件:
_plugins/collection_relative_directory.rb
module Jekyll
class Collection
def relative_directory
@relative_directory ||= (metadata['relative_directory'] && site.in_source_dir(metadata['relative_directory']) || "_#{label}")
end
end
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
761 次 |
| 最近记录: |