ggreer / jekyll-gallery-generator

A Jekyll plugin that generates photo galleries from directories full of images.
Apache License 2.0
367 stars 68 forks source link

List galleries on index page #41

Open chris-gooley opened 6 years ago

chris-gooley commented 6 years ago

I'm a bit new to jekyll and I'm wondering if there is a way to list the galleries on the root index page of the site instead of on a subpage.

My galleries are located in a subfolder called photos which I have specified in the config file. I have tried to reuse the gallery listing loop from gallery_index.html in the index.html file however it doesn't render anything eg

{% for gallery in page.galleries %}

Here is my config file:

gallery:
  dir: 'photos'                   # Path to the gallery
  symlink: false            # false: copy images into _site. true: create symbolic links (saves disk space)
  title: "Photos"           # Title for gallery index page
  title_prefix: "Photos: "  # Title prefix for gallery pages. Gallery title = title_prefix + gallery_name
  sort_field: "date_time"   # How to sort galleries on the index page.
                            # Possible values are: title, date_time, best_image
  thumbnail_size:
    x: 700                  # max width of thumbnails (in pixels)
    y: 450                  # max height of thumbnails (in pixels)
  # The following options are for individual galleries.
  galleries:
    europe:
      best_image: CKG_5420_processed.jpg  # The image to show on the gallery index page. Defaults to the last image.
      name: 'Europe, Dec 2017'
      description: 'Our trip to Europe, December 2017 - January 2018'
    deek_creek_hike:
      best_image: CKG_3308_processed.jpg
      name: 'Deep Creek Hike, August 2017'
      description: 'A hike down to Deep Creek over a couple of nights.'
    with_info:
      info:
        desc: "Gallery Description" # Info fields can be used in custom templates.
everonegraham commented 5 years ago

You have to do 2 for loops for this one.

Do something like:

{% for p in site.pages %}
      {% for gallery in p.galleries %}
       etc...............
      {% endfor %}
{% endfor %}