Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Page Field for page name output

Started by Patrick Hoehn 9 years ago · 7 replies · 862 views
9 years ago

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?

9 years ago

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.

9 years ago

Try only {{ page.slug }}

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

last edited 11/23/17 by Severo Iuliano
9 years ago

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

9 years ago

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

7 years ago

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...

7 years ago

{{page.find(page).title}} did the trick 🙂

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1136 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 61 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 134 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 110 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 129 7 months ago