<p>The browser reads <code>user.userWebsite</code> as a relative URL, not an absolute one, I guess because your <code>user.userWebsite</code> field does not store the protocol, i.e.: http or https. </p>

<p>If you don't specify a protocol in a URL a browser <em>must</em> assume that it is a link to a resource on your own site. The solution is to either store the protocol within userWebsite (probably the best option), or prepend it in your template, e.g.:</p>

<p><code>href="https://{{ user.userWebsite }}"</code></p>

CC BY-SA 4.0
2018-12-22T15:16:50.377Z
I'd recommend prepending it in the template, and doing a find/replace to account for users who may include the protocol. For example, If a user enters "https://..." or "http://..." in your field you'll end up with repeating protocols. This will replace both protocols and output correctly: href="https://{{ user.userWebsite|replace({ 'https://': '', 'http://', '' }) }}" If the protocol is not entered, there will be no replacement, just your field content. This method ensures that you'll always get the secure protocol in your links.
Vaughn D. Taylor
CC BY-SA 4.0
2018-12-18T13:53:04.313Z
2018-12-18T13:53:04.313Z
Seth Warburton
<p>I have links on a partial within my templates, but it seems to be trying to load a template when it should just be loading the outbound href of the <code>&lt;a&gt;</code> tag. I don't have a clue why this would be happening?</p>

<pre><code>  {% if user.userWebsite %}
  &lt;li class="list-inline-item m-1"&gt;
    &lt;a class="btn btn-light" href="{{ user.userWebsite }}" target="_blank"&gt;&lt;i class='bx bx-rss bx-tiny'&gt;&lt;/i&gt;&lt;/a&gt;
  &lt;/li&gt;
  {% endif %}
</code></pre>

<p>Will link out to <code>mysite.com/profile/pinterest.com/username</code> when really it should be going to <code>pinterest.com/username</code></p>

<p>Any ideas to why?</p>

CC BY-SA 4.0
2018-12-16T14:03:29.090Z
Have you checked the links have an http or https at the start of them?
James Greig
<templating>
Partial links not going outbound
# Partial links not going outbound

(Asked by: username_0 on 2018-12-16)

I have links on a partial within my templates, but it seems to be trying to load a template when it should just be loading the outbound href of the  tag. I don't have a clue why this would be happening?
  {% if user.userWebsite %}
  
    
  
  {% endif %}

Will link out to mysite.com/profile/pinterest.com/username when really it should be going to pinterest.com/username
Any ideas to why?

**Tags:** templating
> **Comments:**
> **username_1**: Have you checked the links have an http or https at the start of them?  

---

## 1 answers

### Answer by username_2 on 2018-12-18. Score: 1

The browser reads `user.userWebsite` as a relative URL, not an absolute one, I guess because your `user.userWebsite` field does not store the protocol, i.e.: http or https.

If you don't specify a protocol in a URL a browser *must* assume that it is a link to a resource on your own site. The solution is to either store the protocol within userWebsite (probably the best option), or prepend it in your template, e.g.:

`href="https://{{ user.userWebsite }}"`

> **Comments:**
> **username_3**: I'd recommend prepending it in the template, and doing a find/replace to account for users who may include the protocol. For example, If a user enters "https://..." or "http://..." in your field you'll end up with repeating protocols. This will replace both protocols and output correctly: href="https://{{ user.userWebsite|replace({ 'https://': '', 'http://', '' }) }}" If the protocol is not entered, there will be no replacement, just your field content. This method ensures that you'll always get the secure protocol in your links.  

---

