Difference Between sling:Folder and nt:folder?

Within Apache Sling (and Adobe Experience Manager) are two folder node types: sling:Folder and nt:folder. Within the Sling repository, the folder is a rough equivalent of the file system folder. Apache Jackrabbit defines the nt:folder, Apache Sling adds an additional node type, sling:Folder.

The Jackrabbit folder node, nt:folder, restricts the contents to nodes that are hierarchal in nature. The folders must inherit nt:hierarchyNode or have it as a mixin. A nnt:folder can contain other nt:folders or nt:file nodes. It also contain a short list of other node types such as dam:Asset, vlt:HierarchyNode, nt:linkedFile, cq:EditConfig, sling:MessageEntry, nt:file, sling:Mapping, sling:HierarchyNode, sling:OsgiConfig, cq:Page, sling:Event and nt:folder. All of these have the nt:hierarchyNode mixin or inheritance. Most are files, folders or file/folder-like things. They all support the hierarchal data model.

The nt:folder node restricts what can be used within it. Like any other node types, it can be extended using mixins. To support non-hierarchal nodes inside of nt:folder nodes, use mixins or nest sling:Folder nodes within it.

The sling:Folder node is an overall agreeable node to have around. It extends nt:folder, so it can be used within other hierarchal nodes. But unlike nt:folder, it will put up with having all other types of nodes and properties associated with it. It does not refused anyone.

For strictly controlling the content of your tree, use the nt:node. If the contents of a tree are varied and are not hierarchal nodes, use a the sling:Folder. The sling:Folder node can be used, nested, within a strictly hierarchal node to let non-hierarchal data creep into its tree as well.