Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting Collections Relative Directory: Right Approach? #2518

Closed
budparr opened this issue Jun 14, 2014 · 14 comments
Closed

Setting Collections Relative Directory: Right Approach? #2518

budparr opened this issue Jun 14, 2014 · 14 comments
Labels
frozen-due-to-age has-pull-request Somebody suggested a solution to fix this issue
Milestone

Comments

@budparr
Copy link

budparr commented Jun 14, 2014

This discussion is related to a PR I made to set a configuration variable for a Collection's location in the directory structure. I'm putting it here in an issue to open a broader discussion, if anyone cares, about the best approach to this.

Currently, a Collection's "relative_directory" is set to the Collection label. The documentation is a bit confusing here, because one can apparently access the relative_directory, but not configure it.

I believe it will be better for users, including content creators, to optionally organize their collections into a folder or folders.

So, is it best to be able to set each Collection's directory, or set all Collections' directory, or set aside (thinking of a previous conversation on this) the _includes and _layouts folder so everything else is content?

I've been trying to shove most of my content into a _documents folder and with a bit of finagling (setting permalinks) I can get them to render where I'd like.
Ideally there'd be a way to have a lot of control over the directory structure to keep it organized.

Thoughts appreciated.

@parkr
Copy link
Member

parkr commented Jul 31, 2014

This is a really thorny issue. I feel like the more we allow everything to be configurable, the more we diverge from GitHub Pages and the more confusing life becomes for newcomers. This starts to feel like we're really working to separate all content from the code/styles which is generally good, but it feels like a 🐰 hole that I just don't want to venture down quite yet. Thanks for the idea though!

@parkr parkr closed this as completed Jul 31, 2014
@budparr
Copy link
Author

budparr commented Jul 31, 2014

very well. maybe something for me to lobby for in the 3.0 discussion

@parkr
Copy link
Member

parkr commented Jul 31, 2014

Please do! :)

@parkr parkr reopened this Dec 7, 2014
@parkr parkr added this to the 3.0 milestone Dec 7, 2014
@parkr
Copy link
Member

parkr commented Dec 7, 2014

I think something like this should be considered for Jekyll 3.0. Separating the site code from the content is important. If we can't have proper themes (think @imathis's Octopress Ink), then we could offer something like this so at least content could be encapsulated into one folder. The last piece seems to be _includes and collection paths – they'd have to be configurable the way everything else is.

@vnys
Copy link

vnys commented Dec 22, 2014

I have a use case where it would be very helpful to be able to configure the path to a collections source files. I work on a Jekyll-based site where the assets are published to npm. So the css file for instance is linked from node_modules/afk-assets/css/main.css. I also have a package where I read data from Google Spreadsheets and output yaml-files for use in a collection, but the way things are now I need to copy these files to the collections directory. It would be much easier if I could just configure the path to point to node_modules//source

@alexellison
Copy link

Allowing a collection's directory would also be quite helpful for internationalization (i.e. multi-lingual sites).

There are a few plugins out there (jekyll-multiple-languages-plugin,jekyll-i18n) that function well for posts and pages, but do not support collections. I suspect the lack of support is largely due to the inability to specify a collection's relative directory.

@envygeeks
Copy link
Contributor

I'm gonna try and get this out by 3.0, no promises though. I ran into this issue today and I was bummed out that it didn't work like that out of the box.

@parkr
Copy link
Member

parkr commented Apr 13, 2015

Anyone have time for this?

@maban
Copy link
Contributor

maban commented Apr 20, 2015

👍 for this functionality. Like @budparr, I'm also trying to organise my collections so it's easy for editors to know which files to edit.

@mathematicalcoffee
Copy link

Would love this functionality, I also have many collections that I just want to group into subfolders for cleanliness.

I've just patched one line in jekyll to allow a collection's relative_directory to be set in _config.yml.
You can see it here in my fork : it only neede one line to be changed - in the getter for relative_directory of collection, use the relative_directory in the metadata if it exists, and otherwise use the default (_{#label}).

If this is acceptable, I can try to do tests and documentation (like the contributing page says), though this is my first time using Ruby, so if anyone wants to help that'd be great.

@mathematicalcoffee
Copy link

Alright, I've added documentation and tests (though I am unsure if the tests are rigorous enough).
Currently this is what you do:

In _config.yml, just add relative_directory:

collections:
  my_collection:
    relative_directory: _collections/stupid_name

The resulting collection

  • has label my_collection (regardless of the name of the actual directory, stupid_name in this case - though in practice you'd keep the name of the directory the same as the name of the collection).
  • is copied to <dest>/<collection name>/
  • each document in the collection has path _collections/stupid_name/document-name.md Note this refers to the source path ie _collections/stupid_name, not the destination path ie <collection_name>/. This is the only thing I might think of as being inconsistent.

If you think this modification sounds OK, I'll go ahead and submit a pull request.
The reason I ask first is I've only recently started using jekyll so I'm not sure if the third point is OK, though to me it's similar to when you add a permalink to the front matter, and is fine with me.
I am not sure if this should be explicitly mentioned in the documentation (I have not currently mentioned it).

On that note, the jekyll documentation says path should be "Path to the document relative to the collection's directory", but for me this is instead the absolute path to the document (e.g. /home/amy/sandbox/jekyllsite/_my_collection/index.md under "normal" jekyll (where the collection is in the toplevel _my_collection folder) and _collections/stupid_name/index.md under jekyll after this modification. i.e. in neither case is it a path "relative to the collection's directory"; in the former it's an absolute path and in the latter it's a path relative to the site's directory. But perhaps this is a different issue?

@envygeeks
Copy link
Contributor

We won't know if they are OK until you send a pull request, if you feel that your code is suitable (and to me the idea sounds suitable) then please do submit a PR if you would like and we'd be happy to take a look at the code (I know I won't go digging through your repo to find the code, it's much easier to look at the PR's code.)

@parkr parkr modified the milestones: 3.0, 3.1 Aug 4, 2015
@envygeeks envygeeks added the has-pull-request Somebody suggested a solution to fix this issue label Aug 26, 2015
@envygeeks
Copy link
Contributor

See: #3723

@envygeeks envygeeks removed their assignment Nov 13, 2015
@parkr parkr modified the milestones: 3.2, 3.1 Jan 11, 2016
@parkr parkr modified the milestones: 3.3, 3.2 Jul 25, 2016
@parkr parkr removed this from the 3.3 milestone Sep 28, 2016
@parkr parkr modified the milestones: 3.4, 3.3 Sep 28, 2016
@parkr parkr modified the milestones: 3.4, 3.5 Jan 16, 2017
@DirtyF DirtyF modified the milestones: 3.5, 3.6 Jun 18, 2017
@parkr parkr mentioned this issue Aug 17, 2017
3 tasks
@parkr parkr modified the milestones: v3.6.0, v3.7.0 Sep 21, 2017
@DirtyF
Copy link
Member

DirtyF commented Sep 24, 2017

Closing this now that we have #6331 : users can store all their collections in a folder relative to the source dir with collection_dir 🎉

@DirtyF DirtyF closed this as completed Sep 24, 2017
@jekyll jekyll locked and limited conversation to collaborators Jun 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age has-pull-request Somebody suggested a solution to fix this issue
Projects
None yet
Development

No branches or pull requests

9 participants