使用Jekyll';s用于组织页面/集合的集合相对目录

使用Jekyll';s用于组织页面/集合的集合相对目录,jekyll,Jekyll,我认为设置relative_directory属性将有助于我在不影响所需输出的情况下组织文件,但它似乎被忽略/不用于生成文件。我不希望我的收藏在根目录中,因为我发现在\u资产、\u数据、\u包含、\u布局和其他文件夹旁边有10个收藏文件夹会让人感到困惑 只要输出相同,并且我的页面位于它们自己的目录中,而不需要将permalink放在每个页面的首页,就可以使用修复或替代解决方案 \u config.yaml collections: root: relative_directory:

我认为设置
relative_directory
属性将有助于我在不影响所需输出的情况下组织文件,但它似乎被忽略/不用于生成文件。我不希望我的收藏在根目录中,因为我发现在
\u资产
\u数据
\u包含
\u布局
和其他文件夹旁边有10个收藏文件夹会让人感到困惑

只要输出相同,并且我的页面位于它们自己的目录中,而不需要将
permalink
放在每个页面的首页,就可以使用修复或替代解决方案

\u 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
└── ...
所需输出:

├── ...
├── _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
└── ...

你提到的公关似乎还没有合并

对于3.1.6和下一个3.2:

但看起来是这样的:

\u plugins/collection\u relative\u 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

谢谢你抓住我的错误(还没有合并)。不幸的是,那里的相对_目录插件仍然不能帮助我将文件输出到我想要的路径。:path变量最终包含了整个相对目录,这样我就可以得到像www.example.com/collection//u pages/collection/page.htmlid这样的URL。你找到解决方法了吗?