<p>Using <code>{{category.uri}}</code> is likely just appending to the page's URL. You can use either <code>{{category.url}}</code> or <code>{{siteUrl~category.uri}}</code> to get the full URL.</p>

CC BY-SA 3.0
2016-08-02T15:21:49.887Z
2016-08-02T15:21:49.887Z
Aaron Berkowitz
<p>Looked into this some more: I think this was due to my local development  multiconfig environment having a similar url to the live and the order in which they appear in the config seemed to be responsible for creating some repeated URL segments. I changed the local URL ( MAMP) to something different and {{ category.url }} works fine</p>

CC BY-SA 3.0
2016-08-02T21:42:42.880Z
2016-08-02T21:42:42.880Z
joomkit
<p>My entry template looks for the category of the entry </p>

<pre><code>{% for category in entry.productCategory %}
      {{ category.uri }}
{% endfor %}
</code></pre>

<p>This will output <code>products/[category slug]</code> as I intended. There is only one value in the loop.</p>

<p>As soon as I wrap the category URI in HTML like this:</p>

<pre><code>{% for category in entry.productCategory %}
     &lt;a href="{{ category.uri }}"&gt;view&lt;/a&gt;
{% endfor %}
</code></pre>

<p>The URI doubles: eg the output is repeated so the template renders <code>{{ category.uri }}</code> as</p>

<pre><code>products/[category slug]/products/[category slug]
</code></pre>

<p>Am I missing something in the loop / or Twig behaviour?</p>

CC BY-SA 3.0
2016-08-02T12:00:56.563Z
That is extremely odd behaviour - there is no reason why the HTML would make any difference. What happens if you add one line with HTML and one without within the same loop? Also, what are your category URL formats set to in the CP?
Luke Pearce
CC BY-SA 3.0
2016-08-02T15:52:23.630Z
Same thing as above
joomkit
<templating><category>
Entry template category loop repeats URI when HTML added
# Entry template category loop repeats URI when HTML added

(Asked by: username_0 on 2016-08-02)

My entry template looks for the category of the entry 
{% for category in entry.productCategory %}
      {{ category.uri }}
{% endfor %}

This will output products/[category slug] as I intended. There is only one value in the loop.
As soon as I wrap the category URI in HTML like this:
{% for category in entry.productCategory %}
     view
{% endfor %}

The URI doubles: eg the output is repeated so the template renders {{ category.uri }} as
products/[category slug]/products/[category slug]

Am I missing something in the loop / or Twig behaviour?

**Tags:** templating, category

> **Comments:**
> **username_1**: That is extremely odd behaviour - there is no reason why the HTML would make any difference. What happens if you add one line with HTML and one without within the same loop? Also, what are your category URL formats set to in the CP?  
> **username_0**: Same thing as above  

---

## 2 answers

### Answer by username_2 on 2016-08-02. Score: 1 | Accepted answer

Using `{{category.uri}}` is likely just appending to the page's URL. You can use either `{{category.url}}` or `{{siteUrl~category.uri}}` to get the full URL.


---

### Answer by username_0 on 2016-08-02. Score: 1

Looked into this some more: I think this was due to my local development multiconfig environment having a similar url to the live and the order in which they appear in the config seemed to be responsible for creating some repeated URL segments. I changed the local URL ( MAMP) to something different and {{ category.url }} works fine


---

