Problem using unite-gallery and bibliography plugins on the same page

I am new to Grav and trying to redevelop a long standing web-site for the British Hoverfly Recording Scheme. This will have a page for each species (just under 300 at present) presenting some informations, distribution maps, phenology plots, status and trend information, etc. It also shows pictures of the species if available (currently, images are there for about 80 species). I am using unite-gallery plugin to display these hoverfly images.

The information pesented often involves citing references and, for this purpose, I am using the bibliography plugin.

Bibliography works fine in parts of the site with no image gallery. For example, see this explanation page. However, on the species pages (e.g. Anasimyia lineata), the citations are often not rendered - so something like “according to Ball & Morris, 2024[^HKB6B3NI]” is displayed and there is no reference list at the bottom of the page. But this is not consistent and, sometimes, the bibliography info is rendered correctly. I find that if I clear all caches and then refresh the page it often renders correctly - but if I go elsewhere on the site and return to that page, it fails to render the bibliographic info again!

The header section for species pages is like this

---
title: Anasimyia lineata
taxonomy:
   category: species
unitegallery:
  gallery_theme: compact
bibliography: hover_refs.json
never_cache_twig: true
---

The “never_cache_twig” setting comes from the unite gallery documentation - “Issues with page caching” section. Removing this setting does not seem to make any difference to the issue.

Bibliography plugin needs markdown extra to be enabled and I have done this globally in my system.yaml as suggested in its documentation.

I am using the quark theme, but have used inheritance to make my own version and have over-ridden the blog-item.html.twig partial to call unite-gallery like this

    <div class="e-content">
         {% if page.media.images | length > 0 %}
         <div class="gallery-container {{ page.header.class }}">
              {{ unite_gallery(page.media.images, '{"gallery_theme":"' ~ page.header.unitegallery.gallery_theme ~ '",
                 "slider_enable_text_panel": true, 
                 "slider_textpanel_enable_title": false,
                 "gallery_height": 750
               }') | raw }}"
         </div>
        {% endif %}
        
        {{ page.content|raw }}
    </div>

I have searched extensively for info and code examples for these two plugins and some of the examples for unite-gallery have

process:
    twig: true
    twig_first: true

in the page header. I have tried this (and also changing twing_first to false) but it does not seem to make any difference. I suspect the problem is in some interaction between markdown and twig processing, but it goes well beyong my current level of Grav experience.

I would be very grateful for any suggestions!

Some further investigation.

Looking at the Github source for the bibliography plugin, most of its processing is done in the onProcessContentRaw event.

If I use the debugging facilities in Grav, I can see that, for the normal rendering of species account pages (when the bibliography info is not rendered properly), that event never occurs, although the onProcessContent event does fire. I also note that the total processing time reported is around 58ms.

If I go through the Clear all caches, refresh the page sequence so that the bibliography info does get rendered, the debugger shows that a great deal more processing occurs (as expected!), the onPageContentRaw event is fired and the total processing time is around 500ms of which 290ms is in processes related to building the bibliography.

So my suspicion is that unite-gallery does something, possibly related to caching, that signals that the rest of the page shouldn’t be so fully processed and this prevents the onPageContentRaw event from firing.

@StuartUK, I’ve tried to reproduce the issue on a fresh install of Grav, with Quark, UniteGalery and Bibliography using the “default” template.

I couldn’t reproduce the issue.

Also your webpage Anasimyia lineata seems to be working well. Also when I move to other pages and return.

Notes:

  • I didn’t set never_cache_twig: true
  • I didn’t set any process values
  • Event onProcessContentRaw is called for each page not being cached yet.
  • I could not find any reference to onProcessContent in the docs, nor in the sourcecode of Grav core.

Request:

  • Can you create a minimal reproducible script we can replay?

Sorry, I am away until 30th so won’t be able to do anything until then. Thanks for the response!