Sitepress pages are organized as a hierarchical tree. For example, given the site directory:

├── helpers
├── layouts
└── pages
    └── books
      ├── js-for-newbs.html.haml
      ├── html-for-newbs.html.haml
      └── html-for-newbs
          └── chapter-3.html.haml

Its possible to navigate pages via:

site = "/my/site")
book = site.resources.get("books/html-for-newbs.html")
book.parents      # All parents nodes (books, root)
book.siblings     # All siblings, excluding self (js-for-nebs)
book.parent       # This would return nil since the `book` node doesn't have a page.
book.chidlren     # Returns all of the chapters in `html-for-newbs` (chatper-1 .. chapter-3)

Traversing the site hierachy is very useful for building site navigation components.

Resource manipulation

What if you want to programmatically manipulate your resources? For example, maybe you want to set the layout for the youtube_pages to video. The Site's manipulate function makes that possible:

site = "/my/site")
site.manipulate do |resource|["layout"] = "video" if["video_url"] =~ /youtube/

When the site.resources method is called the rules from manipulate are applied.

If you want to add or remove resources from the manipulate method, just add the second resources argument to the manipulate block:

site = "/my/site")
site.manipulate do |resource, root|
  root.flatten.remove resource if["private"]

Next, read about working with Frontmatter page metadata.