<p>Update.</p>

<p>After looking at the tag model a little more closely, it looks like tags have both a <code>title</code> and <code>slug</code> — so if you use the slug to construct your url then you shouldn't have that problem.</p>

<p>For your tag index:</p>

<pre><code>&lt;ul&gt;
    {% for tag in craft.tags.order('title') %}
        &lt;li&gt;&lt;a href="{{ siteUrl }}tags/{{ tag.slug }}"&gt;{{ tag.title }}&lt;/a&gt;&lt;/li&gt;
    {% endfor %}
&lt;/ul&gt;
</code></pre>

<p>In your tag index page (assuming you are using the <code>tag</code> token in your custom route): </p>

<pre><code>{% set tagEntry = craft.tags.group('myTagGroup').slug(tag).first %}
{% set entries = craft.entries.relatedTo(tagEntry).order('title').limit(null) %}
</code></pre>

CC BY-SA 3.0
2016-12-29T02:57:16.020Z
I modified my original code based on the answer here (http://craftcms.stackexchange.com/questions/881/how-can-i-create-a-visually-weighted-tag-cloud/) I then tried your code with the newer code. I have the following, and while it replaces the spaces with hyphens, I still get 404 errors with tags containing two words.
DevServe
CC BY-SA 3.0
2016-12-29T04:46:47.393Z
My mistake. First, it looks like tags have a slug that is kebab case by default. And secondly, I think that you will need a tag model to use in `relatedTo(tag)`. I updated the answer... see if that works better.
Douglas McDonald
CC BY-SA 3.0
2016-12-27T20:58:16.120Z
2016-12-29T04:44:43.863Z
2016-12-29T04:44:43.863Z
Douglas McDonald
<p>On my page of all tags, it works great except for tags that have more than one word.
The URL is replacing the spaces with %20 as one would expect.</p>

<p><a href="http://www.colorcomputergames.com/tags/" rel="nofollow noreferrer">http://www.colorcomputergames.com/tags/</a></p>

<p>I tried using:</p>

<pre><code>{{ siteUrl }}tags/{{ tag.title | kebab }}
</code></pre>

<p>This works great in changing the %20 to hyphens.
However, if I click on a tag with multiple words I go to page not found. Makes sense as the system doesn't see that tag.</p>

<pre><code>  {% extends "_layout" %}
    {% set title = "Tags" %}
    {% block content %}
    {% for tag in craft.tags.order('title') %}
        &lt;li&gt;&lt;a href="{{ siteUrl }}tags/{{ tag.title | kebab }}"&gt;{{ tag.title }}&lt;/a&gt;&lt;/li&gt;
    {% endfor %}
    {% endblock %}
</code></pre>

<p>So next I tried:</p>

<pre><code>{% extends "_layout" %}
{% set title = "Tags" %}
{% block content %}
{% for tag in craft.tags.order('title') %}
    &lt;li&gt;&lt;a href="{{ siteUrl }}tags/{{ tag.title | url_encode }}"&gt;{{ tag.title }}&lt;/a&gt;&lt;/li&gt;
{% endfor %}
{% endblock %}
</code></pre>

<p>But that wasn't ideal either.</p>

<p>What is the best way to deal with this issue?</p>

<tags><tag>
Best method to handle %20 in tag URLs with multiple words
# Best method to handle %20 in tag URLs with multiple words

(Asked by: username_0 on 2016-12-24)

On my page of all tags, it works great except for tags that have more than one word.
The URL is replacing the spaces with %20 as one would expect.
http://www.colorcomputergames.com/tags/
I tried using:
{{ siteUrl }}tags/{{ tag.title | kebab }}

This works great in changing the %20 to hyphens.
However, if I click on a tag with multiple words I go to page not found. Makes sense as the system doesn't see that tag.
  {% extends "_layout" %}
    {% set title = "Tags" %}
    {% block content %}
    {% for tag in craft.tags.order('title') %}
        {{ tag.title }}
    {% endfor %}
    {% endblock %}

So next I tried:
{% extends "_layout" %}
{% set title = "Tags" %}
{% block content %}
{% for tag in craft.tags.order('title') %}
    {{ tag.title }}
{% endfor %}
{% endblock %}

But that wasn't ideal either.
What is the best way to deal with this issue?

**Tags:** tags, tag

---

## 1 answers

### Answer by username_1 on 2016-12-27. Score: 3 | Accepted answer

Update.
After looking at the tag model a little more closely, it looks like tags have both a title and slug — so if you use the slug to construct your url then you shouldn't have that problem.
For your tag index:

    {% for tag in craft.tags.order('title') %}
        {{ tag.title }}
    {% endfor %}


In your tag index page (assuming you are using the tag token in your custom route): 
{% set tagEntry = craft.tags.group('myTagGroup').slug(tag).first %}
{% set entries = craft.entries.relatedTo(tagEntry).order('title').limit(null) %}

> **Comments:**
> **username_0**: I modified my original code based on the answer here (http://craftcms.stackexchange.com/questions/881/how-can-i-create-a-visually-weighted-tag-cloud/) I then tried your code with the newer code. I have the following, and while it replaces the spaces with hyphens, I still get 404 errors with tags containing two words.  
> **username_1**: My mistake. First, it looks like tags have a slug that is kebab case by default. And secondly, I think that you will need a tag model to use in `relatedTo(tag)`. I updated the answer... see if that works better.  

---

