Use of tag.slug instead of tag.title in a custom route I've followed this guide for creating a routes to list entries with specific tags. It is working fine except that I have muli-word tags so using the tag token from Settings -&gt; Routes gives me urls like 

mysite.com/tags/my%20tag%20name

I'd like to us the tag.slug instead which should allow me to have urls end in .../my-tag-name instead, but I can't figure out how to do it. 

Is there a way to refer to tag.slug in craft/config/routes.php?

If so what should the custom route look like:

'tags/what goes here?' =&gt; 'tags/_tag.html',

Updated

The template code is: 

{% extends "_layout" %}


{% block content %}

{% set tag = craft.tags.title(tag).first() %}

{% if not tag %}
    {% exit 404 %}
{% endif %}

&lt;h2&gt;Entries tagged with “{{ tag.title }}”&lt;/h2&gt;

{% set entries = craft.entries.relatedTo(tag).order('title') %}

{% if entries | length %}

        {% for entry in entries %}
            {{ include('./partials/entryListItem.html', {'entry': entry}) }}
        {% endfor %}
{% else %}
    &lt;p&gt;No entries could be found with that tag.&lt;/p&gt;
{% endif %}

{% endblock %}


and the include points to:

&lt;div class='entry-list-item'&gt;
        &lt;h2&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/h2&gt;
        &lt;p&gt;
          &lt;a href="{{ entry.url }}"&gt;
            &lt;span class="sm-txt"&gt; continue reading&lt;/span&gt;
          &lt;/a&gt;
        &lt;/p&gt;
        {% if entry.tags | length %}
          &lt;p class='sm-txt'&gt;
          {% for tag in entry.tags %}
            &lt;a href="{{ siteUrl }}tags/{{ tag.title | url_encode }}"&gt;{{ tag.title }}, &lt;/a&gt;
          {% endfor %}
          &lt;/p&gt;
        {% endif %}
      &lt;/div&gt;


The route is set in the dashboard tags/(tag token) points to tags/_tag.html

If I change the route to tags/(slug token) I get template error: variable tag does not exist.
You do not have to change your route. Instead modify your template where you are linking the tag.

Instead of using

&lt;a href="{{ siteUrl }}tags/{{ tag.title | url_encode }}"&gt;{{ tag.title }}, &lt;/a&gt;


Use

&lt;a href="{{ siteUrl }}tags/{{ tag.slug }}"&gt;{{ tag.title }}, &lt;/a&gt;


UPDATED

To clarify the above snippet goes in the template that generates the link to take the the user to your _tag.html template, not in the _tag.html template itself.

Your route should be as below:



UPDATE 2

Above snippet updated to match your example above.

UPDATE 3

As the tag variable made available to your template is now the tag’s slug, make sure to update the code to query for the tag model to use the slug param.

{% set tag = craft.tags.slug(tag).first() %}