1. Easy photo galleries with Sigal
    1. CMS vs. SSG
    2. What is Sigal?
    3. Future plans and limitations

Sigal is a "simple static gallery generator" with a straightforward design, a nice feature set, and great themes. It was started as a toy project, but has nevertheless grown into a sizable and friendly community. After struggling with maintenance using half a dozen photo gallery projects along the way, I feel I have found a nice little gem that I am happy to share with LWN readers.

CMS vs. SSG

Sigal is part of a growing family of static site generators (SSG), software that generates web sites as static HTML files as opposed to more elaborate Content Management Systems (CMS) that generate HTML content on the fly. A CMS requires specialized server-side software that needs maintenance to keep up to date with security fixes. That software is always running and exposed on the network, whereas a site generated with an SSG is only a collection of never-changing files. This drastically reduces the attack surface as visitors do not (usually) interact with the software directly. Finally, web servers can deliver static content much faster than dynamic content, which means SSGs can offer better performance than a CMS.

Sigal
showing a video

Having contributed to a major PHP-based CMS for over a decade, I was glad to finally switch to a SSG (ikiwiki) for my own web site three years ago. My photo gallery, however, was still running on a CMS: after running the venerable Gallery software (in hibernation since 2014), then Coppermine, I ended up using Piwigo. But that required a PHP-enabled web server, which meant chasing an endless stream of security issues. While I did consider non-PHP alternatives like MediaGoblin, that seemed too complicated (requiring Celery, Paste, and PostgreSQL). Really, static site generators had me hooked and there was no turning back.

Initially, I didn't use Sigal, as I first stumbled upon PhotoFloat. It is the brainchild of Jason A. Donenfeld—the same person behind the pass password manager that we previously covered and the WireGuard virtual private network (VPN) as well. PhotoFloat is a small Python program that generates a static gallery running custom JavaScript code. I was enthusiastic about the project: I packaged it for Debian and published patches to implement RSS feeds and multiple gallery support. Unfortunately, patches from contributors would just sit on the mailing list without feedback for months which led to some users forking the project. Donenfeld was not happy with the result; he decried the new PHP dependency and claimed the fork introduced a directory traversal vulnerability. The fork now seems to be more active than the original and was renamed to MyPhotoShare. But at that point, I was already looking for alternatives and found out about Sigal when browsing a friend's photo gallery.

What is Sigal?

Sigal was created by a French software developer from Lyon, Simon Conseil. In an IRC interview, he said that he started working on Sigal as a "toy project to learn Python", as part of his work in Astrophysics data processing at the Very Large Telescope in Chile:

A few years ago, I was already working on astrophysics but with another language (IDL): proprietary, and expensive, like MATLAB. Python was getting used more widely, with the birth of Astropy. So wanting to learn Python, I started to contribute to Pelican, and had the idea to do the same for photo galleries. I was using Piwigo, and felt I didn't need the more dynamic parts (comments, stars, etc.). A static site is so much simpler with some JavaScript library to do most of the job. Add some glue to create the pages, and Sigal was born!

Sigal playing a
video

Before starting a new project from scratch, Conseil first looked for alternatives ("Gallerize, lazygal, and a few others") but couldn't find anything satisfactory. He wanted to reuse ideas from Pelican, for example the Jinja2 template engine for themes and the Blinker plugin system, so he started his own project.

Like other static gallery generators, Sigal parses a tree of images and generates thumbnails and HTML pages to show those images. Instead of deploying its own custom JavaScript application for browsing images in the browser, Sigal reuses existing applications like Galleria, PhotoSwipe, and Colorbox. Image metadata is parsed from Exif tags, but a Markdown-formatted text file can also be used to change image or album titles, description, and location. The latest 1.4 release can also read metadata from in-image IPTC tags. Sigal parses regular images using the Pillow library but can also read video files, which get converted to browser-readable video files through the ubiquitous FFmpeg. Sigal has good (if minimal) online documentation and, like any good Python program, can be installed with pip; I am working on packaging it for Debian.

Plugins offer support for image or copyright watermarks. The adjust plugin also allows for minor image adjustments, although those apply to the whole gallery so it is unclear to me how useful that plugin really is. Even novice photographers would more likely make adjustments in a basic image editor like Shotwell, digiKam, or maybe even GIMP before trying to tweak images in a Python configuration file. Finally, another plugin provides a simple RSS feed, which is useful to allow users to keep track of the latest images published in the gallery.

Future plans and limitations

When I asked him about future plans, Conseil said he had "no roadmap":

For me Sigal has been doing its job for a long time now, but the cool thing is that people find it useful and contribute. So my only wish is that this continues and to help the project live for and by its community, which is slowly growing.

Following this lead, I submitted patches and ideas of my own to the project while working on this article. The first shortcoming I have found with Sigal is the lack of access control. A photo gallery is either private or world-readable; there is no way to restrict access to only some albums or photos. I found a way, however, to implement folder password protection using the Basic authentication type for the Apache web server, which I documented in an FAQ entry. It's a little clunky as it uses password files managed through the old htpasswd command. It also means using passwords and, in my usability tests, some family members had trouble typing my weird randomly generated passwords on their tablets. I would have preferred to find a way to use URL-based authentication, with an unguessable one-time link, but I haven't found an easy way to do this in the web server. It can be done by picking a random name for the entire gallery, but not for specific folders, because those get leaked by Sigal. To protect certain pictures, they have to be in a separate gallery, which complicates maintenance.

Sigal basic album view

Which brings us to gallery operation: to create a Sigal gallery, you need to create a configuration file and run the sigal build command. This is pretty simple but I think it can be made even simpler. I have proposed having a default configuration file so that creating a configuration file isn't required to make new galleries. I also looked at implementing a "daemon" mode that would watch a directory for changes and rebuild when new pictures show up. For now, I have settled on a quick hack based on the entr utility but there's talk of implementing the feature directly in the build command. Such improvements would enable mass hosting of photo galleries with minimal configuration. It would also make it easier to create password-less private galleries with unique, unguessable URLs.

Another patch I am working on is the stream plugin, which creates a new view of the gallery; instead of a folder-based interface, this shows the latest pictures published as a flat list. This is how commercial services like Instagram and Flickr work; even though you can tag pictures or group them by folder, they also offer a unified "stream" view of the latest entries in a gallery. As a demonstration of Sigal's clean design, I was able to quickly find my way in the code base to implement the required changes to the core libraries and unit tests, which are now waiting for review.

In closing, I have found Sigal to be a simple and elegant project. As it stands, it should be sufficient for basic galleries, but more demanding photographers and artists might need more elaborate solutions. Ratings, comments, and any form of interactivity will obviously be difficult to implement in Sigal; fans of those features should probably look at CMS solutions like Piwigo or the new Lychee project. But dynamic features are perhaps best kept to purpose-built free software like Discourse that embeds dynamic controls in static sites. In any case, for a system administrator tired of maintaining old software, the idea of having only static web sites to worry about is incredibly comforting. That simplicity and reliability has made Sigal a key tool in my amateur photographer toolbox.

A set of demos is available for readers who want to see more themes and play around with a real gallery.


This article first appeared in the Linux Weekly News.

Vivent les galeries média statiques!

L'approche de Sigal avec des modèles de page qui permet d'organiser visuellement le contenu des albums est très intéressant. L'interface utilisateur non-intrusive laisse la place aux photos. L'architecture de plugins. Ça semble vraiment une bonne solution...

Ma galerie personnelle utilisait le paquet Photofloat de Debian qui n'était plus maintenu. J'avais beau le backporter aux nouvelles versions de mon serveur, il avait un bug qui me désespérait et m'a fait chercher ailleurs: il n'affichait pas les photos si le nom du fichier comportait des accents. En plus, ça dépendait du navigateur utilisé... C'est pour ça que j'ai sauté sur l'occasion pour donner un coup de main quand j'ai vu que le fork MyPhotoShare reprenait le développement. L'interface utilisateur n'est pas (encore) aussi soignée que celle de Sigal. Le code Python était monolithique et n'utilise pas de plugins. J'ai créé un paquet Debian pour l'installer facilement sur mon serveur et dès que nous aurons une version stable, je le partagerai. Il y a maintenant des fonctions de navigation avancée ou de recherche par mot clé dans les métadonnées. Il y a encore place à l'amélioration mais l'interface utilisateur s'améliore de jour en jour...

Le grand avantage des générateurs de galerie statique, c'est qu'on peut en changer facilement. Il suffit d'en installer un autre, scanner les albums de photos et vidéos, et le tour est joué! Pas facile à faire avec un CMS et une base de données au milieu.

Les solutions de galeries média statiques ont un bel avenir.

Comment by Pierre Métras
Created . Edited .