Get a Demo
Table of contents

URL HTML Object

The URL HTML object is used to present the URL field data to your templates. It gives you a structured way to work with and output an HTML link tag.

You can update the link tag's attributes, add custom attributes, and set the link content. If the URL field is configured to show the Link text field, then the URL object will use that text as the link content.

The URL field also lets you set whether the link opens in a new tab or window. That value sets the target attribute for the link tag.

The URL object uses a "content" value for the link text because, in some cases, the content within the link tag could be an image instead of text. "Content" is a more generic term than "text".

Assuming that your URL field has a variable of url, instead of doing this:

<a href="{{ url }}" target="_blank">Some link</a>

You can do this:

{{ url.tag }}

You can use the URL HTML object as a string or as an object.

If you treat it as a string, then it will just output the URL value.

If you use it as an object, you can manipulate the HTML link tag and output the generated link tag.

The examples on this page will assume that the variable for your URL field is "url". Your variable on your website may be different.

Output as a string Link

If you just need the URL value for the URL field and nothing else, then you can simply use the variable name for the URL field.

<a href="{{ url }}" target="_blank">Some link</a>

{# Or, assign the value to something else #}

{% set someOtherVariable = url %}
Get Started With Aptuitiv