2016-07-30 50 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