How to link to page-specific target page within my theme

I am creating a theme which applies a floating button to every page, which should link to the /contact page in this case
How would I go about ensuring that the proper link gets put into the anchor tag in my template? Taking into account localized pages, etc.

I was thinking to put a variable “buttontarget” into each page’s frontmatter, so the twig can construct the proper localized url out of that.
So what should the buttontarget actually contain to identify the page? (the folder name of the page02.contact, just /contact/myform as a full path, or myform, the slug)
and how do i transform whatever the variable contains to a working page link in twig?
again, i need the language routing to still apply for that

why not

<a href="https://mywebsite.com/contact"> </a>

?

do i miss something?

does this mean you want multi-lang website and /contact will be something like /br/contact ?

Well I might want to change the button content link (or hide it on the contact page itself) so I want to work with it somehow being tied to the page it is on.

The localized link might be /contact for english, /kontakt for german and something entirely different for other languages. so just getting language and constructing the link myself probably wont work?

@rappluk,

I’m afraid that <a href="https://mywebsite.com/contact"> </a> will always go to the contact page using the default language. It also won’t translate the link.

See if this Twig snippet works for you:

{% set contactPage = pages.find('/contact') %}
<a href="{{ contactPage.url }}">{{ contactPage.title }}</a>

In combination with frontends like:
German

---
title: Kontakt DE
slug: kontaktDE
---

English:

---
title: Contact EN
slug: contactEN
---

Worked like a charm, thank you :slight_smile: