question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Draft: Nested collections

See original GitHub issue

Is your feature request related to a problem? Please describe.

A site’s page hierarchy can require pages and groups of pages to be created in a nested structure. A content editor working with such a site may need to:

  • create new pages at various levels of the hierarchy
  • create entirely new hierarchy levels within existing levels

Netlify CMS allows new entries to be created in folder type collections, but all entries are more or less siblings in the collection folder. Collections must be added to the CMS configuration for each level of hierarchy.

Describe the solution you’d like

Known use cases involve a single collection description requiring hierarchy only - not distinctly defined collections within other collections. Satisfying this feature request should be doable by simply “enabling nesting” on a folder collection.

  • Allow a collection to contain nested directories
  • Allow nested directories to be created through the CMS UI
  • Allow entries and nested directories to exist in the same parent directory

Configuration

  • Activate by setting an allow_nesting property to true on a collection
  • An optional max_depth setting limiting how deep the hierarchy can go
  • max_depth should default to something sane like 3
  • max_depth should have an internally enforced and documented limit, maybe 5
  • label_singular can apply to all nested directories

UI

  • Collections with nested directories should show as dropdowns in the left sidebar
  • The dropdown should only show directories, not entries
  • A single folder can be selected at a time
  • Only entries directly located in the currently selected folder are visible in the main entries pane
  • An “add” button should show underneath the last nested directory at any level (when expanded)
  • When clicked, a new directory icon is created in its place with an input for naming the new folder Screen Shot 2020-02-10 at 7 18 18 PM

Stretch Goals

Implementation Considerations

  • Nested entries accessed directly via the /edit/ route, the entryName segment currently refers to the filename, but should refer to the path from collection folder to file for nested collections

Open Questions

  • We need a way to rename and delete directories in the UI
  • Creating and editing directories can often result in URL changes, admins will need a way to guard this functionality
  • How do we avoid using raw folder names in the left sidebar? Nested content structures often have a _index.md or index.md file at each level, ideally we could pull values from there for string replacements in the label and description fields.
  • If index.md style files start playing an important role, we need a way to require them in new directories

Describe alternatives you’ve considered

  • Not supporting nested directory creation
  • Supporting distinct collections nested with other collections
  • Adding a config UI to the CMS (#341) and allowing collection creation there

Additional context

Related to: #513

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:50
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
alex-shpakcommented, Jun 19, 2020

Hi! @erezrokah Thank you for your huge effort, not having nested collections was stopping me from using netlifycms.

Question in regard file structure mentioned above, would structure like that work?

level1/
  _index.md
  level2/
     _index.md
     level3.md
     otherPage.md

A mix of regular pages and _index.md pages, (Hugo in this case). Or every page must be a folder with _index.md?

3reactions
joshdcompcommented, Apr 9, 2020

Voted, but also wanted to voice support for this feature…we’re doing quite a bit of hoop-jumping to get around the limitation of no nested dirs in folder collections

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nested Lists - Draft.js
The Draft framework provides support for nested lists, as demonstrated in the Facebook Notes editor. There, you can use Tab and Shift+Tab to ......
Read more >
How do you create a nested list? - Drafts Community
How do you create a nested list? I have tried the four spaces and that doesn't seem to work.
Read more >
This Nest Is A Bit Drafty — Utilizing Nested Lists In Draft.js
In this article I hope to clarify this aspect of Draft.js by demonstrating how to create ordered and unordered list toggles for a...
Read more >
Add nested collections with aggregation in mongoose?
name of collection usually written in plural lowercase letters so I think you should change Author to authors.
Read more >
Nested Record and Array Patterns (Draft JEP) : r/java - Reddit
Cool, but I very rarely find myself using a raw array rather than a list, and when I do, I wrap it into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found