There is not really a very simple way to do this. One thing to keep in mind is that channels
and structures
do not have an 'index' page defined by default. Essentially there are no uri's for channels and structures as a whole, only for the entries within them. You need to create index pages yourself, using:
Singles
(one for each of your index pages), or
- a
Structure
(using different EntryTypes
for the different levels and/or page types), or
- Template files (placed directly in your templates folder)
The other problem is that you may have channels that do not represent pages at all, but are just collections of data to be used elsewhere; likewise, sections do not really have a way to define order. Overall not really a good mechanism to generate nav.
There are, however, other ways to do this.
One solution is to use a dedicated Structure
specifically for navigation (called 'primaryNav' for example) with a related entries field that links to other entries and a custom url field to link to other pages as needed. You can then loop through that structure to generate your nav.
Another option is to define all of your top level pages (what might normally be considered singles) within a structure
using EntryTypes
to differentiate the various page types and define the field requirements (i.e. a structure called 'pages' for example). You can then loop through this structure to generate your nav, using the EntryType
to determine which template code to display.
Either of these techniques can be used with other channels and or structures as needed to generate lower level pages where there are many of the same type (i.e. news, blog, articles, projects, etc.).
There are a lot of good examples of this on the exchange site. Also have a look at craft's nav
tag in the documentation.