Answers.Body: <p>You can <a href="https://craftcms.stackexchange.com/a/5467/689">place your homepage entry in a Structure</a> by setting its slug to <code>__home__</code>.</p>
  
  <p>Doing so causes the entry to answer for the <code>/</code> <em>(empty)</em> URI, and it even places the little "home" icon in place of the Entry's slug in the CP.</p>
  
  <p>However, if you do this, its best not to nest pages under the homepage, because then their URIs would be of the form: <code>__home__/subPageSlug</code></p>
  
  <p>In other words, taking the pages from your example, it's best if your structure can be:</p>
  
  <pre><code>Homepage         (site.com/)
  Subpage 1        (site.com/subpage-1)
  Subpage 2        (site.com/subpage-2)
  Subpage 3        (site.com/subpage-3)
  About            (site.com/about/)
      Subpage 4    (site.com/about/subpage-4)
      Subpage 5    (site.com/about/subpage-5)
  Services         (site.com/services/)
      Subpage 6    (site.com/services/subpage-6)
      Subpage 7    (site.com/services/subpage-7)
  </code></pre>
  
  <p>If you want the benefit of placing the homepage in the Structure, but you need to organize some pages as descendants of the homepage, you <em>could</em>, in theory, rig it up... But it'd get pretty janky:</p>
  
  <ul>
  <li>Give the homepage the special <code>__home__</code> slug.</li>
  <li>Build an <code>index</code> template to answer for the descendant pages by finding the intended entry, setting a <code>entry</code> variable, and extending your regular Page template.</li>
  <li>Create an .htaccess rule to remove the <code>__home__</code> segment from a URL if anybody accidentally lands on it, to prevent duplicate content from appearing at multiple URLs.</li>
  </ul>
  
  <p><strong>However, there are major drawbacks to this second approach:</strong> First, you won't be able to use your entries' <code>url()</code> method... or, you'll have to somehow filter out the offending <code>__home__/</code> segment out of the URL any time you loop through entries or use the <code>{% nav %}</code> tag to generate your site nav. Also, this alternative option also foils Craft's built-in slug-uniqueness checking, so if you're not careful you could end up with duplicate slugs for some pages. In general, I don't recommend it... but it's a fun thought exercise.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-10T23:49:51.967Z
Answers.Text: Best and simplest answer.
Answers.UserDisplayName: kmgdev
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-22T21:28:06.750Z
Answers.LastActivityDate: 2015-02-22T21:43:18.580Z
Answers.LastEditDate: 2017-04-13T12:51:00.303Z
Answers.UserDisplayName: Michael Rog
Answers.Body: <p>You don't have to use an extra single section for the homepage, see here: <a href="https://craftcms.stackexchange.com/q/1467/125">"Add home page to a structure?"</a></p>
  
  <p><strong>Edit:</strong> As this question is slightly different to the one I linked to, I will add some more detail
  on how you can keep your "pages" structure as is. To get the "homepage" entry to load for
  visits to myexample.com, add a template file with the following code to your webroot.</p>
  
  <p><em>index.html</em></p>
  
  <pre><code>{# Get the home page's Entry Model via its slug #}
  {% set entry = craft.entries.section('pages').slug('home').first() %}
  
  {# Load the home page's template from the "pages" structure #}
  {% include "_pages/_entry" %}
  </code></pre>
  
  <p>And for the child entries of "homepage" you could do the same.</p>
  
  <p><em>subpage-1.html</em></p>
  
  <pre><code>{% set entry = craft.entries.section('pages').slug('subpage-1').first() %}
  {% include "_pages/_entry" %}
  </code></pre>
  
  <p>Or as an alternative solution you could instead add custom routes to config/routes.php<br>
  <code>'(?P&lt;slug&gt;subpage-1)' =&gt; '_pages/_entry'</code></p>
  
  <p>And the get the Entry Model in _pages/_entry.html</p>
  
  <pre><code>{% set entry = craft.entries.section('pages').slug(slug).first() %} 
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-22T02:51:58.867Z
Answers.LastActivityDate: 2015-02-22T17:04:56.817Z
Answers.LastEditDate: 2017-04-13T12:51:00.253Z
Answers.UserDisplayName: carlcs
Answers.Body: <p><strong>Updated answer to reflect your added uri requirements.</strong></p>
  
  <p>Given your desired uri patterns, I would recommend moving 'subpage-1', 'subpage-2', and 'subpage-3' to the root of your structure which will make all the uri's the way you want without needing to define any custom routes.</p>
  
  <p>For auto-generating the navigation, you can then simply add some logic to either include or exclude those items, depending on how you want your nav to work. You could do this by checking the 'level' and 'hasDescendants()' (if that's consistent) or by entry type (if you want to use something more specific).</p>
  
  <p>For example, if you wanted to exclude subpages-1,-2,-3 in the site nav (using entryType), but include them in the homepage page nav:</p>
  
  <pre><code>{% set pageEntries = craft.entries.section('pages') %}
  
  &lt;ul id="site-nav"&gt;
      {# skip entries of type 'homepageSubpage' #}
      {% nav entry in pageEntries if not entry.type == 'homepageSubpage'  %}
          &lt;li&gt;
              &lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;
              {% ifchildren %}
                  &lt;ul&gt;
                      {% children %}
                  &lt;/ul&gt;
              {% endifchildren %}
          &lt;/li&gt;
      {% endnav %}
  &lt;/ul&gt;
  
  &lt;ul class="homepage-nav"&gt;
      {# only show entries of type 'homepageSubpage' #}
      {% for entry in pageEntries if entry.type == 'homepageSubpage' %}
          &lt;li&gt;
              &lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;
          &lt;/li&gt;
      {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>You could also of course, leave the 'homepage' entry, sitting next to subpage-1,-2,-3, About, and Services and use the technique as described by carlcs.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-22T11:44:18.663Z
Answers.Text: Hey - thanks for your answer. It's got me 90% of the way there, I hadn't thought of using the include entry.type for the index page too, thanks. I should have been clearer about URL structure though; I've updated my question. Do you know if there's a way to get that URL structure with the include setup?
Answers.UserDisplayName: darylknight
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-22T02:46:42.307Z
Answers.LastActivityDate: 2015-02-22T20:49:34.110Z
Answers.LastEditDate: 2015-02-22T20:49:34.110Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>As far as I can tell, it's mandatory to have a Single as the site index.</p>
  
  <p>I always use a Structure for organising my pages, and different entry types for different page templates. I intend to use a nav tag to output the menu. However, this time my site nav looks like this:</p>
  
  <pre><code>Homepage         (site.com/)
      Subpage 1    (site.com/subpage-1)
      Subpage 2    (site.com/subpage-2)
      Subpage 3    (site.com/subpage-3)
  About            (site.com/about/)
      Subpage 4    (site.com/about/subpage-4)
      Subpage 5    (site.com/about/subpage-5)
  Services         (site.com/services/)
      Subpage 6    (site.com/services/subpage-6)
      Subpage 7    (site.com/services/subpage-7)
  </code></pre>
  
  <p>If I have to use a Single as the home page, how do I put subpages under the home page?</p>
  
  <p>Previously I've used the nav tag, and just hardcoded a link to the home page before the rest of the li's, but that's not going to work this time as the homepage has subpages.</p>
  
  <p>EDIT: I've updated my sitemap to include a URL structure, which is the real challenge here.</p>
  
Tags: <structure><sections><singles>
Title: How to use a Structure including a homepage
ThreadText: # How to use a Structure including a homepage
  
  (Asked by: username_0 on 2015-02-21)
  
  As far as I can tell, it's mandatory to have a Single as the site index.
  
  I always use a Structure for organising my pages, and different entry types for different page templates. I intend to use a nav tag to output the menu. However, this time my site nav looks like this:
  
  ```
  Homepage         (site.com/)
      Subpage 1    (site.com/subpage-1)
      Subpage 2    (site.com/subpage-2)
      Subpage 3    (site.com/subpage-3)
  About            (site.com/about/)
      Subpage 4    (site.com/about/subpage-4)
      Subpage 5    (site.com/about/subpage-5)
  Services         (site.com/services/)
      Subpage 6    (site.com/services/subpage-6)
      Subpage 7    (site.com/services/subpage-7)
  
  ```
  
  If I have to use a Single as the home page, how do I put subpages under the home page?
  
  Previously I've used the nav tag, and just hardcoded a link to the home page before the rest of the li's, but that's not going to work this time as the homepage has subpages.
  
  EDIT: I've updated my sitemap to include a URL structure, which is the real challenge here.
  
  **Tags:** structure, sections, singles
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_4 on 2015-02-22. Score: 4 | Accepted answer
  
  **Updated answer to reflect your added uri requirements.**
  
  Given your desired uri patterns, I would recommend moving 'subpage-1', 'subpage-2', and 'subpage-3' to the root of your structure which will make all the uri's the way you want without needing to define any custom routes.
  
  For auto-generating the navigation, you can then simply add some logic to either include or exclude those items, depending on how you want your nav to work. You could do this by checking the 'level' and 'hasDescendants()' (if that's consistent) or by entry type (if you want to use something more specific).
  
  For example, if you wanted to exclude subpages-1,-2,-3 in the site nav (using entryType), but include them in the homepage page nav:
  
  ```
  {% set pageEntries = craft.entries.section('pages') %}
  
  <ul id="site-nav">
      {# skip entries of type 'homepageSubpage' #}
      {% nav entry in pageEntries if not entry.type == 'homepageSubpage'  %}
          <li>
              <a href="{{ entry.url }}">{{ entry.title }}</a>
              {% ifchildren %}
                  <ul>
                      {% children %}
                  </ul>
              {% endifchildren %}
          </li>
      {% endnav %}
  </ul>
  
  <ul class="homepage-nav">
      {# only show entries of type 'homepageSubpage' #}
      {% for entry in pageEntries if entry.type == 'homepageSubpage' %}
          <li>
              <a href="{{ entry.url }}">{{ entry.title }}</a>
          </li>
      {% endfor %}
  </ul>
  
  ```
  
  You could also of course, leave the 'homepage' entry, sitting next to subpage-1,-2,-3, About, and Services and use the technique as described by username_3.
  
  > **Comments:**
  > **username_0**: Hey - thanks for your answer. It's got me 90% of the way there, I hadn't thought of using the include entry.type for the index page too, thanks. I should have been clearer about URL structure though; I've updated my question. Do you know if there's a way to get that URL structure with the include setup?  
  
  ---
  
  ### Answer by username_1 on 2015-02-22. Score: 7
  
  You can [place your homepage entry in a Structure](https://craftcms.stackexchange.com/a/5467/689) by setting its slug to `__home__`.
  
  Doing so causes the entry to answer for the `/` *(empty)* URI, and it even places the little "home" icon in place of the Entry's slug in the CP.
  
  However, if you do this, its best not to nest pages under the homepage, because then their URIs would be of the form: `__home__/subPageSlug`
  
  In other words, taking the pages from your example, it's best if your structure can be:
  
  ```
  Homepage         (site.com/)
  Subpage 1        (site.com/subpage-1)
  Subpage 2        (site.com/subpage-2)
  Subpage 3        (site.com/subpage-3)
  About            (site.com/about/)
      Subpage 4    (site.com/about/subpage-4)
      Subpage 5    (site.com/about/subpage-5)
  Services         (site.com/services/)
      Subpage 6    (site.com/services/subpage-6)
      Subpage 7    (site.com/services/subpage-7)
  
  ```
  
  If you want the benefit of placing the homepage in the Structure, but you need to organize some pages as descendants of the homepage, you *could*, in theory, rig it up... But it'd get pretty janky:
  
  * Give the homepage the special `__home__` slug.
  * Build an `index` template to answer for the descendant pages by finding the intended entry, setting a `entry` variable, and extending your regular Page template.
  * Create an .htaccess rule to remove the `__home__` segment from a URL if anybody accidentally lands on it, to prevent duplicate content from appearing at multiple URLs.
  
  **However, there are major drawbacks to this second approach:** First, you won't be able to use your entries' `url()` method... or, you'll have to somehow filter out the offending `__home__/` segment out of the URL any time you loop through entries or use the `{% nav %}` tag to generate your site nav. Also, this alternative option also foils Craft's built-in slug-uniqueness checking, so if you're not careful you could end up with duplicate slugs for some pages. In general, I don't recommend it... but it's a fun thought exercise.
  
  > **Comments:**
  > **username_2**: Best and simplest answer.  
  
  ---
  
  ### Answer by username_3 on 2015-02-22. Score: 3
  
  You don't have to use an extra single section for the homepage, see here: ["Add home page to a structure?"](https://craftcms.stackexchange.com/q/1467/125)
  
  **Edit:** As this question is slightly different to the one I linked to, I will add some more detail
  on how you can keep your "pages" structure as is. To get the "homepage" entry to load for
  visits to myexample.com, add a template file with the following code to your webroot.
  
  *index.html*
  
  ```
  {# Get the home page's Entry Model via its slug #}
  {% set entry = craft.entries.section('pages').slug('home').first() %}
  
  {# Load the home page's template from the "pages" structure #}
  {% include "_pages/_entry" %}
  
  ```
  
  And for the child entries of "homepage" you could do the same.
  
  *subpage-1.html*
  
  ```
  {% set entry = craft.entries.section('pages').slug('subpage-1').first() %}
  {% include "_pages/_entry" %}
  
  ```
  
  Or as an alternative solution you could instead add custom routes to config/routes.php  
  `'(?P<slug>subpage-1)' => '_pages/_entry'`
  
  And the get the Entry Model in \_pages/\_entry.html
  
  ```
  {% set entry = craft.entries.section('pages').slug(slug).first() %} 
  
  ```
  
  
  ---
  
  