<p><s>That's by design, slugs are used for building the url to link to a specific element, in this case, a category.</s></p>

<p><strong>Edit:</strong> seems I was wrong on the above, see comment. Leaving the rest of the answer as using the ID offers a solution. </p>

<p>You'll have to use the id to refer to the category as value, like so: </p>

<pre><code>&lt;select name="field-styles" id="field-styles" class="select"&gt;
    &lt;option value=""&gt;Style&lt;/option&gt;
    {% for style in craft.categories.group('productStyles').order('title') %}
    &lt;option value="{{ style.id }}"&gt;{{ style.title }}&lt;/option&gt;
    {% endfor %}
&lt;/select&gt;
</code></pre>

CC BY-SA 3.0
2017-08-30T12:57:55.027Z
Hey Michael, thanks for the response. According to the makers it should work regardless. I believe in your case, the `url` variable would not be available: https://twitter.com/craftcms/status/902730869768691712
Siebird
CC BY-SA 3.0
2017-08-30T13:03:42.613Z
Than I'll gladly wait for someone else to chime in, I'll edit my answer. Still using the ID should work as a (temporary) solution
mrsmn
CC BY-SA 3.0
2017-08-30T12:55:53.470Z
2017-08-30T13:08:13.480Z
2017-08-30T13:08:13.480Z
mrsmn
<p>Just like the title states, the <code>slug</code> variable is not available when a category's url are disabled:</p>

<pre><code>&lt;select name="field-styles" id="field-styles" class="select"&gt;
    &lt;option value=""&gt;Style&lt;/option&gt;
    {% for style in craft.categories.group('productStyles').order('title') %}
    &lt;option value="{{ style.slug }}"&gt;{{ style.title }}&lt;/option&gt;
    {% endfor %}
&lt;/select&gt;
</code></pre>

<p>The snippet of code above works when the URL's are enabled for this category group. When disabled, the input <code>value</code> is blank.</p>

<categories><slug>
Category slug variable is not available when category url's are disabled
# Category slug variable is not available when category url's are disabled

(Asked by: username_0 on 2017-08-30)

Just like the title states, the slug variable is not available when a category's url are disabled:

    Style
    {% for style in craft.categories.group('productStyles').order('title') %}
    {{ style.title }}
    {% endfor %}


The snippet of code above works when the URL's are enabled for this category group. When disabled, the input value is blank.

**Tags:** categories, slug


---

## 1 answers

### Answer by username_1 on 2017-08-30. Score: 1

That's by design, slugs are used for building the url to link to a specific element, in this case, a category.
Edit: seems I was wrong on the above, see comment. Leaving the rest of the answer as using the ID offers a solution. 
You'll have to use the id to refer to the category as value, like so: 

    Style
    {% for style in craft.categories.group('productStyles').order('title') %}
    {{ style.title }}
    {% endfor %}

> **Comments:**
> **username_0**: Hey Michael, thanks for the response. According to the makers it should work regardless. I believe in your case, the `url` variable would not be available: https://twitter.com/craftcms/status/902730869768691712  
> **username_1**: Than I'll gladly wait for someone else to chime in, I'll edit my answer. Still using the ID should work as a (temporary) solution  

---

