Answers.Body: <p>Personally, I'd use segments for that. Something like:</p>
  
  <pre><code>{% if craft.request.lastSegment == "page" %}
     do something
  {% endif %}
  </code></pre>
  
  <p>or</p>
  
  <pre><code>{% if craft.request.segments(1) == "page" %}
     do something
  {% endif %}
  </code></pre>
  
  <p>These days, though, when not making a dynamic nav, I tend to pass a variable to my extended layouts or nav include. I find it much more flexible / robust than just relying on URL structures or segments.</p>
  
  <p>In child template</p>
  
  <pre><code>{% set currentNav = "home" %}
  </code></pre>
  
  <p>or</p>
  
  <pre><code>{% include 'includes/_nav' with {'currentNav':'home'} %}
  </code></pre>
  
  <p>In include or extended layout</p>
  
  <pre><code>{% if currentNav == "home" %}
     do something
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-02T01:22:23.103Z
Answers.Text: That 2nd example should read segment, not segments...
Answers.UserDisplayName: Leah
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-02T03:27:34.370Z
Answers.Text: Hey Anna, not sure about this. Here is what the doc says: http://buildwithcraft.com/docs/templating/craft.request#segments
Answers.UserDisplayName: Jérôme Coupé
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-03T00:46:45.393Z
Answers.Text: Yeah I saw that. Not sure either - segmentS wasn't working for me, but segment was. Go figure :P
Answers.UserDisplayName: Leah
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-30T06:49:42.030Z
Answers.LastActivityDate: 2014-10-30T06:58:36.223Z
Answers.LastEditDate: 2014-10-30T06:58:36.223Z
Answers.UserDisplayName: Jérôme Coupé
Answers.Body: <p>In addition to the options Jerome mentioned, you can also test for the Entry Type, which typically would be different for homepage vs blog, etc.</p>
  
  <pre><code>{% if entry.type == 'home' %}
  ...
  {% endif %}
  </code></pre>
  
  <p>Switch also works well here.</p>
  
  <pre><code>{% switch entry.type %}
     {% case 'home' %}
     ...
     {% case 'blog' %}
     ...
     {% default %}
     ...
  {% endswitch %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-30T07:35:55.070Z
Answers.LastActivityDate: 2014-10-30T07:35:55.070Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>I am trying to simply change a <code>nav</code> element if one homepage and another if on the blog or another page.</p>
  
  <p>I can the following to display if I set the following statement to <code>!=</code> </p>
  
  <pre><code>{% if craft.request.getUrl() == 'http://testsite.com/page/' %}
      {{siteUrl}}
  {% endif %}
  </code></pre>
  
  <p>However I can't figure out what that is returning as no matter what I put it doesn't work. </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-10-30T07:28:30.557Z
Comments.Text: You can always see what a variable returns by outputting it like so {{ craft.request.getUrl() }}
Comments.UserDisplayName: naboovalley
Tags: <templating>
Title: If url do something
ThreadText: # If url do something
  
  (Asked by: username_0 on 2014-10-30)
  
  I am trying to simply change a `nav` element if one homepage and another if on the blog or another page.
  
  I can the following to display if I set the following statement to `!=`
  
  ```
  {% if craft.request.getUrl() == 'http://testsite.com/page/' %}
      {{siteUrl}}
  {% endif %}
  
  ```
  
  However I can't figure out what that is returning as no matter what I put it doesn't work.
  
  **Tags:** templating
  
  > **Comments:**
  > **username_1**: You can always see what a variable returns by outputting it like so {{ craft.request.getUrl() }}  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2014-10-30. Score: 10
  
  Personally, I'd use segments for that. Something like:
  
  ```
  {% if craft.request.lastSegment == "page" %}
     do something
  {% endif %}
  
  ```
  
  or
  
  ```
  {% if craft.request.segments(1) == "page" %}
     do something
  {% endif %}
  
  ```
  
  These days, though, when not making a dynamic nav, I tend to pass a variable to my extended layouts or nav include. I find it much more flexible / robust than just relying on URL structures or segments.
  
  In child template
  
  ```
  {% set currentNav = "home" %}
  
  ```
  
  or
  
  ```
  {% include 'includes/_nav' with {'currentNav':'home'} %}
  
  ```
  
  In include or extended layout
  
  ```
  {% if currentNav == "home" %}
     do something
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_3**: That 2nd example should read segment, not segments...  
  > **username_2**: Hey Anna, not sure about this. Here is what the doc says: http://buildwithcraft.com/docs/templating/craft.request#segments  
  > **username_3**: Yeah I saw that. Not sure either - segmentS wasn't working for me, but segment was. Go figure :P  
  
  ---
  
  ### Answer by username_4 on 2014-10-30. Score: 6
  
  In addition to the options Jerome mentioned, you can also test for the Entry Type, which typically would be different for homepage vs blog, etc.
  
  ```
  {% if entry.type == 'home' %}
  ...
  {% endif %}
  
  ```
  
  Switch also works well here.
  
  ```
  {% switch entry.type %}
     {% case 'home' %}
     ...
     {% case 'blog' %}
     ...
     {% default %}
     ...
  {% endswitch %}
  
  ```
  
  
  ---
  
  