# $field->toPages()

Returns a pages collection from a yaml list of page ids in the field

****

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

****

```php
$field->toPages(string $separator = 'yaml'): Kirby\Cms\Pages
```

## Parameters

| Name | Type | Default | Description |
| ---- | ---- | ---- | ---- |
| `$separator` | `string` | `'yaml'` | Can be any other separator to split the field value by |

## Return type

`Kirby\Cms\Pages`

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


<info>
The `toPages()` field method only returns published (listed and unlisted) pages, not drafts.
</info>

## Examples

### Text file

```kirbycontent
Title: My page
----
Text: Some text
----
Related:

- blog/article-a
- blog/article-b
```

### Template

```php
<h2>Related articles</h2>
<ul>
  <?php foreach ($page->related()->toPages() as $related): ?>
  <li>
    <a href="<?= $related->url() ?>">
      <?= $related->title() ?>
    </a>
  </li>
  <?php endforeach ?>
</ul>
```