Radical Design Course by Jack McDade

From the creator of Statamic

Learn how to make your websites standout and be remembered.

Taking your approach on designing things actually makes it fun, more natural, and overall easier.

— Dominik, Developer

Link Tag

Generate fully qualified URLs with the option to include your domain.

Overview

You can create a fully qualified URL to any resource, asset, or page on your site using a path relative string.

For example, if you had a link to <a href="fanny-packs">, it would be broken if you left that relative area of the site. By using the link tag you can ensure it's relative to your site root, and include the domain if needed.

{{ link to="fanny-packs" }}
{{ link to="fanny-packs" absolute="true" }}
{{-- Using Antlers Blade Components --}}
<s:link to="fanny-packs" />
<s:link to="fanny-packs" absolute="true" />>
 
{{-- Using Fluent Tags --}}
{{ Statamic::tag('link')->to('fanny-packs') }}
{{ Statamic::tag('link')->to('fanny-packs')->absolute(true) }}
/fanny-packs
https://example.com/fanny-packs

You can also link to entries using their ID directly:

{{ link id="1715c9a8-0662-4ca7-b9ea-1ad642431fae" }}
{{-- Using Antlers Blade Components --}}
<s:link id="1715c9a8-0662-4ca7-b9ea-1ad642431fae" />
 
{{-- Using Fluent Tags --}}
{{ Statamic::tag('link')->id('1715c9a8-0662-4ca7-b9ea-1ad642431fae') }}
/the-pages-slug

When using Multi-Site, the URL automatically links to the entry on the current site. If you want to link to a specific site instead, you can add the in parameter:

{{ link id="1715c9a8-0662-4ca7-b9ea-1ad642431fae" in="spanish" }}
{{-- Using Antlers Blade Components --}}
<s:link id="1715c9a8-0662-4ca7-b9ea-1ad642431fae" in="spanish" />
 
{{-- Using Fluent Tags --}}
{{ Statamic::tag('link')->id('1715c9a8-0662-4ca7-b9ea-1ad642431fae')->in('spanish') }}
 
/es/el-asdf-de-la-pagina

Parameters

to|src

string

Generate a URL to this relative path string.

absolute

boolean

Make the URL absolute if it isn't already. Default: false.

id

string

ID of the entry to link to.

in

string

Handle of the site you want to link to (only when using Multi-Site).

Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →