# $field->toLink()

Wraps a link tag around the field value. The field value is used as the link text

****

- Source: <https://github.com/getkirby/kirby/tree/5.5.3/config/methods.php#L210>

****

```php
$field->toLink(mixed $attr1 = null, mixed $attr2 = null): string
```

## Parameters

| Name | Type | Default | Description |
| ---- | ---- | ---- | ---- |
| `$attr1` | `mixed` | `null` | Can be an optional Url. If no Url is set, the Url of the Page, File or Site will be used. Can also be an array of link attributes |
| `$attr2` | `mixed` | `null` | If `$attr1` is used to set the Url, you can use `$attr2` to pass an array of additional attributes. |

## Return type

`string`

This method modifies the existing `$field` object it is applied to and returns it again.

## Aliases

You can use the following aliases for this field method in your template:

- `$field->link(…)`

## Examples

The following create a link (a-tag) with the title as link text and the page url as url.

```php
<?= $page->title()->toLink() ?>
```