Skip to content

Sitemap

Devin edited this page Jun 29, 2020 · 6 revisions

The sitemap is the spine of the Frontman application. It holds every page of your site.

The sitemap is a SitemapTree, and every node on the sitemap is a SitemapTree as well.

A SitemapTree can have many SitemapTrees, and one or zero Resources. Consider a site with the following pages:

  • /about/people/
  • /about/people/idris/
  • /about/people/naomi/

The node for /about/ contains one SitemapTree (/about/people/) and no Resource, because there is no page at /about/.

The node for /about/people/ contains a Resource (the page itself), and two SitemapTrees (/about/people/idris/ and /about/people/naomi/).

There are two ways to access a node from the sitemap:

  • At the class level, Frontman has a static hash of URLs and their associated SitemapTrees. This access level is useful when trying to access a URL directly, regardless of what SitemapTree the current page belongs to.

    sitemap = Frontman::App.instance.sitemap_tree.from_url('/about/')
  • At the instance level, Frontman provides a child property that lets you traverse the entire hierarchy of a specific SitemapTree. This access level is useful when you want to render a set of nodes belonging to a specific SitemapTree.

    current_tree.children.each do |child|
      puts child.resource.path
    end