Using the Jekyll relative_directory directory to organize pages / collections

I thought installing relative_directory (Jekyll Collection Docs) (github PR) to help me keep my files organized without prejudice to my desired output, but it seems to be ignored / not used to create files. I do not want my collection in the root directory, because it's difficult to confuse ~ 10 collectible folder located next to the _assets, _data, _includes, _layoutsand others.

Corrections or alternative solutions are welcome as long as the output is the same and my pages are in their own directory, without the need to place permalinkfront-matter on each separate page.

_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

Directory structure:

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

, PR, , .

3.1.6 3.2 jekyll -:

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

, :

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

Source: https://habr.com/ru/post/1649601/


All Articles