<p>Since you are building a custom URL, you shouldn't be using <a href="http://buildwithcraft.com/docs/templating/functions#url" rel="nofollow"><code>url()</code></a> here, since it automatically appends your values to the <code>siteUrl</code>. Try one of these instead:</p>

<p><code>&lt;a href="{{ url(section.handle ~ '/types/' ~ entryType.handle) }}"&gt;</code></p>

<p>-or-</p>

<p><code>&lt;a href="{{ siteUrl ~ section.handle ~ '/types/' ~ entryType.handle }}"&gt;</code></p>

CC BY-SA 3.0
2015-04-13T07:43:07.353Z
Have tried it before. And with the same effect. I keep looking for the root of a problem.
Dominik Krulak
CC BY-SA 3.0
2015-04-13T07:46:25.010Z
Well, just after I posted my last comment, I think I've fixed it. I don't know, if it's correct, but it seems to be working. `<a href="{{ url(section.handle ~ '/types/' ~ entryType.handle) }}">{{ entryType.name|ucfirst }}</a>` ?
Dominik Krulak
CC BY-SA 3.0
2015-04-13T19:24:26.213Z
That should work! I updated my answer to include your solution and another using `siteUrl`
Aaron Berkowitz
CC BY-SA 3.0
2015-04-12T20:19:03.757Z
2015-04-13T19:24:02.683Z
2015-04-13T19:24:02.683Z
Aaron Berkowitz
<p>I'm building an entry type's menu, automatically populated with several sections. A route for dynamic menu had to be also created.</p>

<p><strong>Code</strong></p>

<pre><code>{% set section = craft.sections.getSectionByHandle('sectionHandle') %}
{% set entryTypes = section.getEntryTypes() %}

{% for entryType in entryTypes %}
    &lt;li&gt;
        &lt;a href="{{ section.handle }}{{ url('types/'~entryType.handle) }}"&gt;
            {{ entryType.name|ucfirst }}
        &lt;/a&gt;
    &lt;/li&gt;
{% endfor %}
</code></pre>

<p><strong>Output</strong></p>

<ul>
<li>craft.dev/sectionHandle/types/entryType.handle</li>
</ul>

<p>When I access the link, It gets crazy.</p>

<p><strong>Output</strong></p>

<ul>
<li>craft.dev/sectionHandle/types/sectionHandle/types/entryType.handle</li>
</ul>

<p>I was trying everything I know, but Whatever I add in front of <code>{{url('types/'~entryType.handle) }}</code>, it gets duplicated.</p>

<url>
How do I build a link from variables?
# How do I build a link from variables?

(Asked by: username_0 on 2015-04-12)

I'm building an entry type's menu, automatically populated with several sections. A route for dynamic menu had to be also created.
Code
{% set section = craft.sections.getSectionByHandle('sectionHandle') %}
{% set entryTypes = section.getEntryTypes() %}

{% for entryType in entryTypes %}
    
        
            {{ entryType.name|ucfirst }}
        
    
{% endfor %}

Output

craft.dev/sectionHandle/types/entryType.handle

When I access the link, It gets crazy.
Output

craft.dev/sectionHandle/types/sectionHandle/types/entryType.handle

I was trying everything I know, but Whatever I add in front of {{url('types/'~entryType.handle) }}, it gets duplicated.

**Tags:** url

---

## 1 answers

### Answer by username_1 on 2015-04-12. Score: 5 | Accepted answer

Since you are building a custom URL, you shouldn't be using [`url()`](http://buildwithcraft.com/docs/templating/functions#url) here, since it automatically appends your values to the `siteUrl`. Try one of these instead:

-or-

> **Comments:**
> **username_0**: Have tried it before. And with the same effect. I keep looking for the root of a problem.  
> **username_0**: Well, just after I posted my last comment, I think I've fixed it. I don't know, if it's correct, but it seems to be working. `<a href="{{ url(section.handle ~ '/types/' ~ entryType.handle) }}">{{ entryType.name|ucfirst }}</a>` ?  
> **username_1**: That should work! I updated my answer to include your solution and another using `siteUrl`  

---

