Get url page via twig


#1

I have a URL: /7.0/7.1/7.1.1/7.1.1.4, but trying to access “7.1.1.4” via twig. The

{{uri.path}}

Outputs the entire path.


#2

You want to output the page slug: https://learn.getgrav.org/themes/theme-vars#slug


#3

I ended up using:

{{uri.path|split('/')|last|split('-')|first}}

since in needed the actual URI that was passed. I am using this on the error.md page, so I couldn’t use the slug because it would always show up as “error”