I’m putting together my first Grav site and rather liking it but I’ve hit a problem I just can’t seem to figure out. I do have a working solution but it requires a hard typed path that would break if I ever moved the page folder to a different location. That is obviously not the best of solutions.
I have the following set up
user/pages folder
pages
- 01.bobs-burgers
- default.en.md
- burger-header.jpg
inside default.en.md
title: Kitchens
banner:
enabled: true
url: 'burger-header.jpg'
inside default twig
{% if header.banner.enabled %}
<div class="banner"{% if header.banner.url is not empty %} style="background-image: url('{{ header.banner.url }}')"{% endif %}></div>
{% endif %}
---
What I am trying to do is have an image defined within the default.en.md file be placed within the theme twig. The problem is the image is in the pages folder and I can not get the correct path to it. I can hard code it in the header to be url: '/user/pages/01.bobs-burgers/burger-header.jpg' but then if I ever move the folder the path breaks.
I'm looking for either something that can go in the .md header like url: $pageFolderPath.'/burger-header.jpg' or something that can go in the twig file like url="{{ pageFolderPath }},{{ header.banner.url }}" where pageFolderPath is resolved to "/user/pages/01.bobs-burgers/"
or maybe I'm doing this in a bone headed way and I need some straightening out XD