How to get a url on a multi-language site to a page other than the current one?

Hi, I’m building a multi-language site. There’s a nav menu item in the header that simply should link to a certain page on the same site, with the current language involved. How to get the url for that? A very basic thing, still I just don’t get the logic yet.

Urls are always language relative, so you don’t have to do anything specific, unless you want to link to another language. Or do you want to know how you can access a specific page? If so, you can use the page() helper, e.g.

<?php if ($p = page('path-to-page')) {
  echo $p->url();
}
?>

Thanks for the quick reply!

For some reason that does not work. I replaced the ‘path-to-page’ with my pagename, as the page resides on the same level, but it doesn’t produce anything.

You have to pass the complete path to the page, not just the UID, e.g. the page is in /content/projects/project-a you would have to pass

page('projects/project-a')

(without content, but all the rest)

1 Like

Wonderful, thanks for your help!