# Link

A link is a text box that takes a full URL or a path on your site. Pair it with a label in an object to make a button.

## The field

`f.link()` stores a string and shows a text box. Editors type a full address, `https://example.com/pricing`, or a path on the site, `/company/about-us`. The view renders it as an `href`:

File: `components/sections/Hero.schema.ts`

```ts
    buttons: f.list(f.object({ label: f.text(), href: f.link() })).max(2),
```

File: `components/sections/Hero.tsx`

```tsx
                  <a key={i} className={i === 0 ? "button" : "button button--outline"} href={b.href}
```

The box takes only a target the site will render: `https://`, `http://`, `mailto:`, `tel:`, a path starting with `/`, `#` or `?`. Anything else, a `javascript:` address say, is marked under the box as the editor types, and Publish refuses it.

A path is stored as typed, not looked up: on a multilingual site each language's link holds that language's own URL, such as `/fi/yritys`, and a link to a page does not follow it when its slug changes.

A link with a label is an object of two fields, as above. A list of those objects is a row of buttons, capped with `.max()`.

## Links inside richtext

Text inside a [richtext](https://smoodly.io/docs/fields/richtext.md) field links through the `link` mark of its toolset, which editors apply from the toolbar. On the site, `RichText` renders only safe targets: `http`, `https`, `mailto`, `tel`, and paths on the site. Anything else renders as plain text.

Next, [Choices](https://smoodly.io/docs/fields/choices.md).
