How to print "query" field url

I would like to have a field, that would allow to link to other site pages, so I created this:

  buttonlink:
    label: Button link
    type: pages
    query: site.index

And in template added code:

<a href="<?= $site->url() ?>/<?= $section->buttonlink() ?>"> some text </a>

But on page I get something like this:

http://example.com/en/-%20%3E%20%20blog/blog-post-title
or
http://example.com/en/-%20contact

-%20 - or more code is added.

The pages field stores its content in yaml format:

buttonlink:

- mypage

To fetch content from that field, you can use the toPage() (for a single page) or the toPages() (for multiple pages) methods

Your code then would look like this:

<?php if($p = $section->buttonlink()->toPage()): ?>
<a href="<?= $p->url() ?>"><?= $p->title() ?></a>
<?php endif ?>

Thank you very much, now all is working fine.