Gallerydeluxe with multiple galleries

Hi there,

I came across this project, which is great! The Pig.js integration is exciting!

I’ve tried adapting the gallerydeluxe_starter to accomodate more than one folder, so separate galleries, yet so far my attempts have failed.

In the most simple case, the idea would be to have a directory structure like so:


Has anyone tried to do this?

My idea was to start a new site, add a random template, add gallerydeluxe as a module, then copy the layouts/index.html into a layouts/_default/single.html, and try and retrieve the current directory to pass it to the Pig.js logic:

{{ $currentDir := .File.Dir  | replaceRE "/$" "" }}
{{ $gallery := partial "gallerydeluxe/init.html" (dict "sourcePath" (printf "%v" $currentDir)) }}

Unfortunately, even though this does not throw any error on my end, I am unable to access any of the galleries I have. No surprise there, I suppose, since the are headless in the starter, but even if I change that, nothing, neither error nor any access to any links.

Any pointers would be greatly appreciated, thanks!

1 Like

This may be related Add some kind of portfolio support (i.e. multiple galleries) · Issue #17 · bep/gallerydeluxe · GitHub

My photo interest has increased the last few months, so the above will happen soonish.

That said, it should be possible to make what you want work, but it’s hard to debug this from the little I see.

Also, looking at the above, I’m not sure why I didn’t just allowed people to just pass a slice of image to init.html. I will try to make that an option soonish, which should make this easier.

OK, I have pushed a new version of the theme, for usage see

With the above you can construct your images slice from whatever you want.

1 Like

This was absolutely related, I saw this and thought I’d try my hand at a less general solution first!

Great, thanks so much, I’ll have a look!

1 Like

Hi again.

I’m afraid I am still unable to reach the desired effect, most likely due to my insufficient knowledge of Hugo templating…

As said, I’m trying to modify the starter in order to have an arbitrary structure of folders in content, and some of them containing an with gallerydeluxe: true in the frontmatter. I’m using your index.html code as the _default/single.html, with this simple modification:

  {{ if .Params.gallerydeluxe }}
    {{ $images := .Resources.ByType "image" }}
    {{ $gallery := partial "gallerydeluxe/init.html" (dict "images" $images) }}

I have several folders with an and images at various nested levels in content (not a huge amount of images in each folder).

I get this error:

execute of template failed at <partial "gallerydeluxe/init.html" (dict "images" $images)>: error calling partial: partial "gallerydeluxe/init.html" timed out after 30s. This is most likely due to infinite recursion.

At first, I thought the recursion problem, if it is indeed that, was caused by the default files that are created and then handled automatically by hugo. Then I thought I could add a frontmatter parameter to filter that, and wrapped the invocations of the partials with {{ if .Params.gallerydeluxe }} ... {{ end }}, but I still get the recursion issue, unfortunately.

I wonder what might be the cause of this issue. (I did increase the timeout to 360s, but to no avail.)

If you could push your failing project to a public GitHub repo, it would be easier to help you. The devil is in the detail, and I cannot trouble shoot by your code fragments.

1 Like

That said, image processing (the first run before it’s cache) can take some time, so what you can try is to put:

timeout = '10m'

or something in. your site config.

1 Like

Thanks for this! Ok, so I created a fork of your original repo, with a few dummy galleries, that seems to work.

A few things I had to do, and which I don’t fully understand:

  • removing the headless: true seems to be required for the galleries to load;
  • without the _default/list.html, which I added as the hyperlinks all gave me ‘Page Not Found’, and that I was planning to use to reveal where the pages were, it didn’t seem to work, none of the pages would be displayed.
  • not sure why, but the Exif logic fails on my system (go1.20.4 linux/amd64 )

I suppose one could imagine using this to have a starter template that can be integrated into a theme, where e.g. the home page, list, single, would already be defined.

For maximal modularity, would it be correct to say that we would need to define a new Kind of page for the gallery, that would trigger the gallery logic, so that this would not clash with the standard definition of single and index? (Not sure if it is the right vocabulary.)