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-packshttps://example.com/fanny-packs
Link to Entries
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
Generate a URL to this relative path string.
absolute
Make the URL absolute if it isn't already. Default: false
.
id
ID of the entry to link to.
in
Handle of the site you want to link to (only when using Multi-Site).