Page Field for page name output

Hi, I’m new to Grav and here is my first problem: I discovered that the Page Field outputs the complete path to the page but I need the output to be the page name only. With this output I want to generate an anchor link, e.g. #contact but with the output of the Page Field I get something like #/home/contact (it’s a modular page). What is the best practise to achieve this?

Hi, maybe it might be fine slug ( see )

Hi @iusvar,
Thanks for your answer but it didn’t solve my problem. When I use the Page Field, the output is already “/home/contact”, so adding slug to the front end output {{ page.header.linked_page.slug }} does not work.

Try only {{ page.slug }}

… if you want to know all of the Page items, write {{ page|dump }}

Thank you for your help, but I used an other approach to get this fixed

should generally use {{ page.url }}#something

Would have been nice to know about this “other approach” since I am facing the exact same issue here.

I am looping through all the pages listed in the pages field (multiple: true). But the output is already the path, not an object. page.slug is empty. {{ page }} returns /parent/page-slug but I need the Title of the page and also the slug alone…

{{page.find(page).title}} did the trick :slight_smile: