The aim is to add into the navigation bar an arbitrary route or the parent page url, the route being defined in the parent content file, eg., inner.md
. (I am also using onpage_menu: true
)
I have a header field
up:
route: /operation
And inside a twig file inner.htlm.twig
{% set p_url = (header.up.route) ? header.up.route : page.parent.url %}
The problem is that the url being generated is <grav root>/operation
, and not <grav root>/user/pages/operation
How do I access the base route for pages in twig?
Could it be that you are confusing paths and routes?
'/user/pages/operationis a (partial filesystem) path and URL's in Grav do not contain
user/pages`.
Perhaps you can use the value of filePathClean() and go from there.
1 Like
I admit, I don’t completely understand the distinction between paths and routes, at least how to handle or generate them.
Thank you for pointing me to filePathClean(), which led me to other functions in Theme Variables. I had not thought of looking there for information on Twig functions.
Now I can go and experiment a bit to get something that I want.
Regards