What it is
CreateGallery is a ruby script and a set of layouts to generate a photo gallery in Jekyll.
CreateGallery uses the following libraries:
To install EXIFR:
gem install exifr
The only required file is
If you want to take stock of the existing gallery layouts, you have two options:
- Download this repository and copy the files in the
_layoutsdirectory in your Jekyll website
- Use this repository as a Jekyll skeleton website.
If you are going to create your own gallery layouts, you can simply download the
How it works
Different from other Jekyll gallery generators,
create_gallery.rb is a pre-processor.
That is, the script takes as input a list of directories containing pictures (either
png) and it populates them with a set of thumbnails and a set of Jekyll files to nicely display the pictures as a gallery (where “nicely” depends upon how good you are with CSS and HTML gallery generation).
More specifically, given a directory
gallery_1 containig the the files
create_gallery.rb generates the following files in the
- Thumbnails (210×150 by default):
img-1-thumb.jpg: thumbnail of
img-2-thumb.jpg: thumbnail of
- A textile page showing all the thumbnails in the gallery:
- (Optionally) a textile page for each picture:
Warning: The script silently overwrites the above mentioned files in the directory in which it is invoked.
- Add a directory containing pictures to your Jekyll website
- Run the
create_gallery.rbscript passing as input the directory name
jekyllto generate your website
create_gallery.rb uses relative URLs in the pages it generates. This should be ok in (nearly) all usage scenarios.
If you prefer to generate absolute pathnames, invoke the script using the
--url option. In this case the directory portion of the URL will include the path of the file relative to the location in which the script has been invoked. When generating absolute URLs, therefore, it is a good idea to invoke the script from the root directory of your website.
$ cd <root of jekyll sources> $ ls -R gallery_1 gallery_1: img-1.jpg img-2.jpg $ ./create_gallery.rb gallery_1 --url http://www.example.com/my_photo_website --pages [... which silently generates: - gallery_1/index.textile - gallery_1/1.textile - gallery_1/1-thumb.textile] $ jekyll --url http://www.example.com/my_photo_website
The website will have the following URLs:
Customizing the Output
Nearly every aspect of the gallery can be configured using the layout files available in the
_layouts directory. Have a look at the
_layouts directory for more information.
Things to experiment:
- Customize the information which is displayed
- Embed the galleries in your website using your website look and feel
create_gallery.rbis compatible with Gallerific
- Generate your fancy layout
If you customize or create a new layout, please consider sending it to me, so that I can include it in the distribution. (Another possibility is forking the repository, add the new layout in the
_layouts directory, and send a pull request.)
Usage: create_gallery [--pages] [--url URL] [--geometry <geometry>] <directory> ... Input: <directory> ... one or more directory with JPG or PNG pictures Output: a set of Jekyll file to present the pictures as a gallery Optional arguments: --geometry NNNxMMM generate thumbnails of given geometry (for the gallery file) --pages generate one individual page per picture (rather than having the gallery point directly to the pictures) --url URL make all links absolute Some examples of thumb geometries: 330x220, 210x150 (app default), 90x90
Distributed under the terms of the MIT License
$ create_gallery.rb gallery_1 $ jekyll
… or opportunities for developers:
- More interaction: ask before overwriting files
- Generate scaled version of the images for the individual pages (at the moment pictures in individual pages are scaled using a width property of a css)
- Support paging for larger galleries
- Support gallery metadata (e.g. gallery caption, etc) (notice that this can be done now by manually editing the generated files)
- Full support/improved support for Exif data
- Integration with map services for pictures with GPS coordinates
- Generation of an index pages including all galleries (with possible support for thumbnails)
- Support for themes (when more than a layout is available)