Answers.Body: <p>You might do something like this, concerned that you want to set current on active category.</p>
  
  <pre><code>{% set categorySlug = craft.request.getLastSegment() %} 
  
  {% nav category in craft.categories.group('blogCategories') %}
      {% set current = (category.slug == categorySlug) %}
      &lt;a class="button button--outline-blue 
         {% if current %} current{% endif %}
         href="{{ category.url }}"&gt;
         {{ category.title }}
      &lt;/a&gt;
  {% endnav %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-02T11:49:08.147Z
Answers.Text: Thanks. That's setting 'current' on all rather than just the one that matches the current slug.
Answers.UserDisplayName: sarah3585
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-02T12:24:43.540Z
Answers.Text: You may try now.
Answers.UserDisplayName: Dominik Krulak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-02T09:20:13.370Z
Answers.LastActivityDate: 2015-11-02T12:24:14.863Z
Answers.LastEditDate: 2015-11-02T12:24:14.863Z
Answers.UserDisplayName: Dominik Krulak
Body: <p>I'm trying to match the 2nd part of the slug with the category title to then place a 'current' class on the link.</p>
  
  <p>Something like:</p>
  
  <pre><code>{% nav category in craft.categories.group('blogCategories') %}
  
      &lt;a class="button button--outline-blue {% if craft.request.getSegment(2) == '{{ category.title }}' %}current{% endif %}" href="{{ category.url }}"&gt;{{ category.title }}&lt;/a&gt;
  
  {% endnav %}
  </code></pre>
  
Tags: <categories><getsegment>
Title: getSegment matching category title
ThreadText: # getSegment matching category title
  
  (Asked by: username_0 on 2015-11-02)
  
  I'm trying to match the 2nd part of the slug with the category title to then place a 'current' class on the link.
  
  Something like:
  
  ```
  {% nav category in craft.categories.group('blogCategories') %}
  
      <a class="button button--outline-blue {% if craft.request.getSegment(2) == '{{ category.title }}' %}current{% endif %}" href="{{ category.url }}">{{ category.title }}</a>
  
  {% endnav %}
  
  ```
  
  **Tags:** categories, getsegment
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-11-02. Score: 4 | Accepted answer
  
  You might do something like this, concerned that you want to set current on active category.
  
  ```
  {% set categorySlug = craft.request.getLastSegment() %} 
  
  {% nav category in craft.categories.group('blogCategories') %}
      {% set current = (category.slug == categorySlug) %}
      <a class="button button--outline-blue 
         {% if current %} current{% endif %}
         href="{{ category.url }}">
         {{ category.title }}
      </a>
  {% endnav %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks. That's setting 'current' on all rather than just the one that matches the current slug.  
  > **username_1**: You may try now.  
  
  ---
  
  