# $field->toStructure()

Converts a yaml field to a Structure object

****

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

****

```php
$field->toStructure(): Kirby\Cms\Structure
```

## Return type

`Kirby\Cms\Structure`

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


While the <a href="https://getkirby.com/docs/reference/templates/field-methods/yaml">`yaml` method</a> returns a simple associative PHP array for <a href="https://getkirby.com/docs/reference/panel/fields/structure">structured field</a> content, the `toStructure` method gives you a full blown Kirby Collection which makes it possible to use Kirby's chaining syntax.

## Examples

### Text file
```kirbycontent
Title: My page
----
Accounts:
  - name: Mastodon
    url: https://mastodon.social/@getkirby
  - name: GitHub
    url: https://github.com/getkirby
```
### Template

```php
<h1>On the web</h1>
<ul>
  <?php foreach ($page->accounts()->toStructure() as $account): ?>
  <li>
    <a href="<?= $account->url() ?>">
      <?= $account->name() ?>
    </a>
  </li>
  <?php endforeach ?>
</ul>
```