victoriadrake / hugo-theme-sam

A Simple and Minimalist theme for Hugo with a focus on typography and content.
https://victoria.dev/hugo-theme-sam/
Apache License 2.0
421 stars 176 forks source link

Multiple Galleries #35

Closed DigiJo closed 5 years ago

DigiJo commented 6 years ago

Is it possible to have multiple galleries? For example, a wedding gallery and a portrait gallery.

I can think of maybe two ways which might answer this.

  1. Name the files according to their grouping and save in image folder. Use get.resource or resources.match.

  2. Duplicate the current gallery on the theme and rename folder, links and components.

Any ideas of which is best?

Thanks for your time and for producing the theme. It's amazing.

victoriadrake commented 6 years ago

We can take advantage of Hugo's Content Types to achieve this. If I want to add a new gallery called "portraits" at the ultimate URL "https://example.com/portraits/", I can simply create a new content folder that looks like this:

content/
 └── portraits/
    └── images/
    |   ├── file_1.jpg
    |   ├── file_2.jpg
    |   └── file_3.jpg
    └── _index.md

The front matter of _index.md would look like:

---
title: "Portraits"
type: "gallery"
url: "/portraits"
---

That's it!

I've added to the README to hopefully make this more clear. Thanks for the question @DigiJo!

erikparr commented 5 years ago

Hi I followed these instructions, including file structure and editing _index.md but new galleries are only displaying images in the "gallery" folder. Am I missing something? Thanks

victoriadrake commented 5 years ago

@erikparr Doesyour site repo live on GitHub? If so, would you link it please so I can take a look?

Also, please make sure you have the latest version of the theme.