Structures

Postified on May 31st, 2019

Structures are one of the last significant changes yet to be covered here on the blog. Today's reveal day, so let's just get right into it.

Structures Replace "Pages"

Statamic 2's "Pages" feature has been replaced by a significantly more flexible and reusuable pattern we're calling Structures. "Pages" were essentially a special collection that were kept separate from the others, whose folder structure (on the file level) also dictated their URLs. For example, if you had a content/pages/about/team.md file, it would have the URL /about/team. You could then use the {{ nav }} tag to loop through all the Pages and build your navigation.

It was pretty simple and very useful. However, what if you wanted to include a link in that nav to something else? A subdomain, entries in a collection, an external URL, or even just text? You had to rethink everything. Maybe you could use a Grid and some relationship fields in a global to define all the links in your nav. Or maybe just hardcode it.

Given these use cases, we went back to the drawing board and came up with something more useful.

Structures Come in Two Flavors

Structure Purposes

Collection

You can now create a Collection Structure that works just the way Pages do in v2 (except you have as many as you'd like). Each entry in the collection will be automatically added to the structure tree and be assigned a URL based on its place in the tree. We'll make sure that Pages migrate cleanly to a Collection Structure when upgrading from v2.

Hand-crafted Navigation

You can also now create a Navigation Structure that exists simply to build a nav out of entries that already exist, as well as freeform links and text (non-link) elements. This will let you build a nav with external links, section headers, and so on.

Structure Link Tree

Assemble whatever links you want into a structure tree, loop through them in your template, write whatever HTML you'd like, and tada. Easily manageable navs. And that's Structures!

Structure Links
Jack McDade
Jack McDade, Creator of Statamic
Creator of Statamic

Copyright 2019 ⚔️ Statamic