Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-02T15:21:49.887Z
Answers.LastActivityDate: 2016-08-02T15:21:49.887Z
Answers.UserDisplayName: Aaron Berkowitz
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-02T21:42:42.880Z
Answers.LastActivityDate: 2016-08-02T21:42:42.880Z
Answers.UserDisplayName: joomkit
Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-02T12:00:56.563Z
Comments.Text: 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?
Comments.UserDisplayName: Luke Pearce
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-08-02T15:52:23.630Z
Comments.Text: Same thing as above
Comments.UserDisplayName: joomkit
Tags: <templating><category>
Title: Entry template category loop repeats URI when HTML added
ThreadText: # 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 %}
       <a href="{{ category.uri }}">view</a>
  {% 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
  
  
  ---
  
  