Hi!
Bear in mind, I am a novice user of grav.
Circumstances of my problem:
I am setting up a simple blog and I regularly want to add multiple images to a blog-post.
I am trying to solve this problem by using the simple gallery solution described in the cookbook combined with the Featherlight plugin.
My site uses the Saturn theme which I already nearly fully copied over after I made a child theme from it through inheritance.
My main issue is that I don’t fully understand the cookbook gallery description. Maybe I miss some basic stuff.
The structure of my site is very simple. Currently I only have a 02.blog/
and a 03.contact/
folder. (There is home/
dir without 01.
, I don’t need it so this way hidden)
In the 02.blog
folder I have my blog-posts’ folders like 20170524
etc. Inside in a blog-post folder I have an item.md
.
Earlier I thought I will create an img
folder where I planned to store all th e relevant images to the actual blog-post.
I have created a gallery.html.twig
according to the description of the gallery cookbook recipe in the grav documentation.
That I placed into my theme’s templates/
folder (actually tried multiple places, including partials/
and modular/
, finally just left it in the root of templates/
).
After that I have created an empty gallery.md
in my blog-post’s img/
folder. And now comes up the actual problem: that is I don’t know how to reference/include/import the gallery.md
file’s content
into my blog-post (item.md
). I made several attempts edited this and that, tried find()
twig function. I will not list everything here I tried.
The point is I don’t know how to include other md
file’s content.
Finally I moved my images together with item.md
and deleted img/
folder. I forgot to mention, I have meta.yaml
files as well for every image. In these there is a title and description meta tag created for the images.
I will return to this later. So after I had all my images, meta.yaml files, and the blog-post’s item.md
together in one folder, I allowed the parsing of twig code in my md/html page and copied over the relevant section from
gallery.html.twig
into item.md'
Now that looks like this, also I have combined it with featherlight which is working as expected.
-
{% for image in page.media.images %}
-
{{ image.lightbox(1024,768).cropResize(200,200).html }}
{{ image.meta.title }}
{{ image.meta.description }}
{% endfor %}
This is working, I have an auto-generated list of images with description under it, but I have read it somewhere and noticed it, that the page renders a bit slowly because twig parsing is allowed
in the md/html file.
So, finally, my question is, how can I more elegantly solve this issue? How should I properly apply the cookbook gallery solution? What am I missing, how can I include into a blog-post the generated content of a gallery template? Also this is not just question of elegance, the proper way would be to not repeat the this code block over and over again in every blog-post where I want to add some images. This solution not allows me to make separate image-galleries on one page, it just outputs a big block of all my images. The ideal solution would be to paste a gallery template’s content where I want to, from whatever folder that contains images.
This was the main issue. Also I promised to get back to the meta.yaml
file. My other problem is, that for some reason the title meta tag’s value is not showing up. I have title and description and only description’s string value is parsed. Why could this be??
Thanks!