Answers.Body: <p>There are two very different questions here, but I will try my best to answer them both!</p>
  
  <p>The first being "<strong>How do I hide a page from the navigation?</strong>"</p>
  
  <p>The simplest way I can think of for this, that is also controllable through Craft, is to create a simple "Hide from navigation" <a href="http://buildwithcraft.com/docs/lightswitch-fields" rel="nofollow">Lightswitch</a> field, and add this to your entry types.</p>
  
  <p>When looping through entries for the navigation, you can check whether the lightswitch has been checked, and if it has, don't show that entry in the nav:</p>
  
  <pre><code>{% for entry in craft.entries.section('lorem').hideFromNavigation(0) %}
      --
  {% endfor %}
  </code></pre>
  
  <p>The second question is "<strong>How do I redirect to the homepage if someone visits /services?</strong>"</p>
  
  <p>This can be achieved with the <code>redirect</code> <a href="http://buildwithcraft.com/docs/templating/redirect" rel="nofollow">tag</a>. In your <code>services/index.twig</code> template file, you can simply add:</p>
  
  <pre><code>{% redirect siteUrl %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-20T19:05:25.170Z
Answers.Text: Thx for the *hideFromNavigation* tip. Exactly what I was looking for! :-)
Answers.UserDisplayName: Mario
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-20T19:24:38.990Z
Answers.Text: Had to use this syntax to exclude entries with active lightswitch: *.hideFromNavigation('not 1')*
Answers.UserDisplayName: Mario
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-09T16:19:14.780Z
Answers.Text: Not trying to hide from navigation, just want to remove link from the "Services" page and/or remove page entirely and modify code above accordingly. Any ideas?
Answers.UserDisplayName: frshjb373
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-08T22:44:38.783Z
Answers.LastActivityDate: 2014-12-08T22:44:38.783Z
Answers.UserDisplayName: Jamie Wade
Answers.Body: <p>You need to add a conditional to either only run for the parent items OR exclude the children items. Using depth level would do it:</p>
  
  <p>So instead of:</p>
  
  <pre><code>&lt;a href="{{ page.navigationUrlOverride ? page.navigationUrlOverride : page.url }}"&gt;
  </code></pre>
  
  <p>try:</p>
  
  <pre><code>{% if page.navigationUrlOverride and page.level == '1' %}
      &lt;a href="{{ page.navigationUrlOverride }}" /&gt;
  {% else %}
      &lt;a href="{{page.url}}" /&gt;
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-09T22:56:39.393Z
Answers.Text: This doesn't allow you to override level 2 entries.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-10T00:25:35.943Z
Answers.Text: Precisely. I kept it simple to illustrate how to work around the children adopting the value of the parent while still maintaining the use of the children tag.
Answers.UserDisplayName: Jarrett Barnett
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-09T22:06:48.653Z
Answers.LastActivityDate: 2014-12-09T22:06:48.653Z
Answers.UserDisplayName: Jarrett Barnett
Answers.Body: <p>As I wrote in the comments section, you could work around this strange behavior of the nav tag by replacing it with nested for loops. Use <a href="http://buildwithcraft.com/docs/templating/entrymodel#getDescendants" rel="nofollow"><code>getDescendants(1)</code></a> to get the child entries of each top-level entry.</p>
  
  <pre><code>{% for page in pageItems %}
      &lt;li&gt;
          &lt;a href="{{ page.navigationUrlOverride ? page.navigationUrlOverride : page.url }}"&gt;
              {{ page.navigationTitle ? page.navigationTitle|nl2br : page.title }}
          &lt;/a&gt;
  
          {% set subPageItems = page.getDescendants(1) %}
          {% if subPageItems %}
              &lt;div class="drop"&gt;
                  &lt;ul&gt;
                      {% for subPage in subPageItems %}
                          &lt;a href="{{ page.navigationUrlOverride ? page.navigationUrlOverride : page.url }}"&gt;
                              {{ page.navigationTitle ? page.navigationTitle|nl2br : page.title }}
                          &lt;/a&gt;
                      {% endfor %}
                  &lt;/ul&gt;
              &lt;/div&gt;
          {% endif %}
      &lt;/li&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-12-09T23:11:59.920Z
Answers.LastActivityDate: 2014-12-09T23:11:59.920Z
Answers.UserDisplayName: carlcs
Answers.Body: <p>You can also do a simple if/else to hide the href link using a lightswitch toggle. Using Jamie's hideFromNavigation lightswitch from above, you could do the following:</p>
  
  <pre><code>{% set entries = craft.entries.section('pages') %}
  &lt;ul id="nav"&gt;
      {% nav entry in entries %}
          &lt;li&gt;
              &lt;a  {% if entry.hideFromNavigation %} href="#" {% else %} href="{{ entry.url }}" {% endif %}&gt;{{ entry.title }}&lt;/a&gt;
              {% ifchildren %}
                  &lt;ul&gt;
                      {% children %}
                  &lt;/ul&gt;
              {% endifchildren %}
          &lt;/li&gt;
      {% endnav %}
  &lt;/ul&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-28T18:52:55.953Z
Answers.LastActivityDate: 2017-06-28T18:52:55.953Z
Answers.UserDisplayName: EParks
Body: <p>Trying to output navigation:</p>
  
  <ul>
  <li>Home </li>
  <li>About </li>
  <li>Services
  <ul>
  <li>Sub 1</li>
  <li>Sub 2</li>
  <li>Sub 3 </li>
  </ul></li>
  <li>List item</li>
  <li>Testimonials </li>
  <li>Contact </li>
  <li>Get Quote</li>
  </ul>
  
  <p>I'd like to remove the link to the Services page, preferably to <code>&lt;a href"#"&gt;</code> and if accessed through url, redirect to homepage.</p>
  
  <p>Here's how I'm currently outputting nav:</p>
  
  <pre><code>        {# get menu items #}
          {% set pageItems = craft.entries.section('services').level('&lt;= 2') %}
          {# % set pageItems = craft.entries.level('&lt;= 2') %# }
  
          {# Output the sub menu #}
          &lt;ul&gt;
              &lt;li&gt;&lt;a href="{{ siteUrl }}"&gt;Home&lt;/a&gt;&lt;/li&gt;
              {% set entry = craft.entries.slug('about').first %}
              &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
  
              {% nav page in pageItems %}
              &lt;li&gt;
                  &lt;a href="{{ page.navigationUrlOverride ? page.navigationUrlOverride : page.url }}"&gt;
                      {% if page.navigationTitle %}{{ page.navigationTitle|nl2br }}{% else %}{{ page.title }}{% endif %}
                  &lt;/a&gt;
                  {% ifchildren %}
                  &lt;div class="drop"&gt;
                      &lt;ul&gt;
                          {% children %}
                      &lt;/ul&gt;
                  &lt;/div&gt;
                  {% endifchildren %}
              &lt;/li&gt;
              {% endnav %}
          &lt;/ul&gt;
          &lt;ul&gt;
              {% set entry = craft.entries.slug('testimonials').first %}
                  &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
              {% set entry = craft.entries.slug('contact').first %}
                  &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
              {% set entry = craft.entries.slug('get-a-quote').first %}
                  &lt;li&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
  </code></pre>
  
  <p>Any help is much appreciated. Thanks in advance.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-12-09T09:21:26.483Z
Comments.Text: Your code does actually look good to me? You use a plain text field `navigationUrlOverride` to overwrite the URL with `#` from the CP, right?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-12-09T20:55:35.977Z
Comments.Text: I tried that, but it adds `#` to all children. Want the children links to work.
Comments.UserDisplayName: frshjb373
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-12-09T21:07:14.763Z
Comments.Text: Sounds like a bug to me. You could work around this by replacing the `nav` tag with nested `for` loops.
Comments.UserDisplayName: carlcs
Tags: <navigation><templating>
Title: Remove page link from navigation
ThreadText: # Remove page link from navigation
  
  (Asked by: username_0 on 2014-12-08)
  
  Trying to output navigation:
  
  * Home
  * About
  * Services
    + Sub 1
    + Sub 2
    + Sub 3
  * List item
  * Testimonials
  * Contact
  * Get Quote
  
  I'd like to remove the link to the Services page, preferably to `<a href"#">` and if accessed through url, redirect to homepage.
  
  Here's how I'm currently outputting nav:
  
  ```
          {# get menu items #}
          {% set pageItems = craft.entries.section('services').level('<= 2') %}
          {# % set pageItems = craft.entries.level('<= 2') %# }
  
          {# Output the sub menu #}
          <ul>
              <li><a href="{{ siteUrl }}">Home</a></li>
              {% set entry = craft.entries.slug('about').first %}
              <li><a href="{{ entry.url }}">{{ entry.title }}</a></li>
  
              {% nav page in pageItems %}
              <li>
                  <a href="{{ page.navigationUrlOverride ? page.navigationUrlOverride : page.url }}">
                      {% if page.navigationTitle %}{{ page.navigationTitle|nl2br }}{% else %}{{ page.title }}{% endif %}
                  </a>
                  {% ifchildren %}
                  <div class="drop">
                      <ul>
                          {% children %}
                      </ul>
                  </div>
                  {% endifchildren %}
              </li>
              {% endnav %}
          </ul>
          <ul>
              {% set entry = craft.entries.slug('testimonials').first %}
                  <li><a href="{{ entry.url }}">{{ entry.title }}</a></li>
              {% set entry = craft.entries.slug('contact').first %}
                  <li><a href="{{ entry.url }}">{{ entry.title }}</a></li>
              {% set entry = craft.entries.slug('get-a-quote').first %}
                  <li><a href="{{ entry.url }}">{{ entry.title }}</a></li>
          </ul>
  
  ```
  
  Any help is much appreciated. Thanks in advance.
  
  **Tags:** navigation, templating
  
  > **Comments:**
  > **username_1**: Your code does actually look good to me? You use a plain text field `navigationUrlOverride` to overwrite the URL with `#` from the CP, right?  
  > **username_0**: I tried that, but it adds `#` to all children. Want the children links to work.  
  > **username_1**: Sounds like a bug to me. You could work around this by replacing the `nav` tag with nested `for` loops.  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_2 on 2014-12-08. Score: 5
  
  There are two very different questions here, but I will try my best to answer them both!
  
  The first being "**How do I hide a page from the navigation?**"
  
  The simplest way I can think of for this, that is also controllable through Craft, is to create a simple "Hide from navigation" [Lightswitch](http://buildwithcraft.com/docs/lightswitch-fields) field, and add this to your entry types.
  
  When looping through entries for the navigation, you can check whether the lightswitch has been checked, and if it has, don't show that entry in the nav:
  
  ```
  {% for entry in craft.entries.section('lorem').hideFromNavigation(0) %}
      --
  {% endfor %}
  
  ```
  
  The second question is "**How do I redirect to the homepage if someone visits /services?**"
  
  This can be achieved with the `redirect` [tag](http://buildwithcraft.com/docs/templating/redirect). In your `services/index.twig` template file, you can simply add:
  
  ```
  {% redirect siteUrl %}
  
  ```
  
  > **Comments:**
  > **username_0**: Not trying to hide from navigation, just want to remove link from the "Services" page and/or remove page entirely and modify code above accordingly. Any ideas?  
  > **username_3**: Thx for the *hideFromNavigation* tip. Exactly what I was looking for! :-)  
  > **username_3**: Had to use this syntax to exclude entries with active lightswitch: *.hideFromNavigation('not 1')*  
  
  ---
  
  ### Answer by username_4 on 2014-12-09. Score: 2
  
  You need to add a conditional to either only run for the parent items OR exclude the children items. Using depth level would do it:
  
  So instead of:
  
  ```
  <a href="{{ page.navigationUrlOverride ? page.navigationUrlOverride : page.url }}">
  
  ```
  
  try:
  
  ```
  {% if page.navigationUrlOverride and page.level == '1' %}
      <a href="{{ page.navigationUrlOverride }}" />
  {% else %}
      <a href="{{page.url}}" />
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_1**: This doesn't allow you to override level 2 entries.  
  > **username_4**: Precisely. I kept it simple to illustrate how to work around the children adopting the value of the parent while still maintaining the use of the children tag.  
  
  ---
  
  ### Answer by username_1 on 2014-12-09. Score: 2
  
  As I wrote in the comments section, you could work around this strange behavior of the nav tag by replacing it with nested for loops. Use [`getDescendants(1)`](http://buildwithcraft.com/docs/templating/entrymodel#getDescendants) to get the child entries of each top-level entry.
  
  ```
  {% for page in pageItems %}
      <li>
          <a href="{{ page.navigationUrlOverride ? page.navigationUrlOverride : page.url }}">
              {{ page.navigationTitle ? page.navigationTitle|nl2br : page.title }}
          </a>
  
          {% set subPageItems = page.getDescendants(1) %}
          {% if subPageItems %}
              <div class="drop">
                  <ul>
                      {% for subPage in subPageItems %}
                          <a href="{{ page.navigationUrlOverride ? page.navigationUrlOverride : page.url }}">
                              {{ page.navigationTitle ? page.navigationTitle|nl2br : page.title }}
                          </a>
                      {% endfor %}
                  </ul>
              </div>
          {% endif %}
      </li>
  {% endfor %}
  
  ```
  
  
  ---
  
  ### Answer by username_5 on 2017-06-28. Score: 1
  
  You can also do a simple if/else to hide the href link using a lightswitch toggle. Using username_2's hideFromNavigation lightswitch from above, you could do the following:
  
  ```
  {% set entries = craft.entries.section('pages') %}
  <ul id="nav">
      {% nav entry in entries %}
          <li>
              <a  {% if entry.hideFromNavigation %} href="#" {% else %} href="{{ entry.url }}" {% endif %}>{{ entry.title }}</a>
              {% ifchildren %}
                  <ul>
                      {% children %}
                  </ul>
              {% endifchildren %}
          </li>
      {% endnav %}
  </ul>
  
  ```
  
  
  ---
  
  