2016-07-30 22 views
4

我认为设置relative_directory(Jekyll Collection Docs)(github PR)属性被设置将帮助我保持我的文件的组织而不影响我所需的输出,但它似乎被忽略/不用于生成文件。我不希望我的收藏夹位于根目录中,因为我发现有与〜_assets,_data,_includes,_layouts等相邻的〜10个收藏夹会令人困惑。使用Jekyll集合relative_directory来组织页面/集合

只要输出结果相同,并且我的页面位于各自的目录中,则无需在每个页面上放置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 

目录结构:

├── ... 
├── _layouts 
├── _pages 
│   ├── root 
│   │ ├── about.html 
│   │ └── contact.html 
│   ├── root_worthy 
│   │ ├── quickstart.html 
│   │ └── seo-worthy-page.html 
│   └── docs 
│    ├── errors.html 
│    └── api.html 
├── _posts 
└── index.html 

所需的输出:

├── ... 
├── _site 
│   ├── about.html 
│   ├── contact.html 
│   ├── quickstart.html 
│   ├── seo-worthy-page.html 
│   └── docs 
│    ├── errors.html 
│    └── api.html 
└── ... 

回答

2

看来ŧ你提到的公关仍然没有合并。

对于3.1.6和3.2旁边,jekyll code is still

@relative_directory ||= "_#{label}" 

the requester made a plugin,看起来像这样:

_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 
+1

感谢赶上我的错误(尚未合并)。不幸的是,那里的relative_directory插件仍然不能帮助我将文件输出到我想要的路径。 :path变量最终包含整个relative_directory,这样我就可以访问www.example.com/collection/_pages/collection/page.html – KFunk

+0

这样的网址了吗? – lux