Package: hugophotoswipe
HugoPhotoSwipeHugoPhotoSwipe is a command line application to easily create and managePhotoSwipealbums when using theHugostatic website generator.Useful linksDemo page generated with Hugo and using
PhotoSwipeDemo page source codeWiki with full walkthrough of the
demoBlog with introduction to
HugoPhotoSwipeWhy?I created my personal website using Hugo, so all source documents are
created as Markdown files. I wanted to have photo albums on the site as
well, using the PhotoSwipe viewer. I also wanted to easily set photo
descriptions, quickly update albums when photos change, and have
responsive image sizes and thumbnails automatically generated.
HugoPhotoSwipe makes all this easily possible.See my blog postherefor more
about my motivations for making this tool.How?PhotoSwipe requires some Javascript and a specific HTML format to work,
and Hugo generally works with Markdown files. So, this program creates a
markdown file for Hugo to work with based on Hugoshortcodes. These
shortcode are then used to create the HTML code that PhotoSwipe needs.
See thedocsdirectory for the shortcodes.InstallationHugoPhotoSwipe is available on PyPI, you can install it easily with pip:$ pip install hugophotoswipeAfter installation, you should have anhpscommand line program. Try
runninghps -Vto check this.UsageThis is a brief overview. See theWikifor a full
description.Create a new directory for HugoPhotoSwipe and switch to it. For
instance:$ mkdir hugophotos
$ cd hugophotosNext, initialize a HugoPhotoSwipe configuration with:$ hps initThis creates a new HugoPhotoSwipe configuration file, calledhugophotoswipe.yml. This is aYAML
file. In this configuration file,
you need to set at least themarkdown_dirandoutput_dirvariables.
These are respectively the directory where the markdown needs to be
placed and the directory where the processed photos need to be placed.
You may also want to set theurl_prefixvariable, which is added
before the path to the photo files.Create a new album using:$ hps newHugoPhotoSwipe will ask you for the name of the new album, and create a
directory with that name for you. Try to keep the names short, they are
not the final title of the album. Spaces in the name are automatically
replaced with underscores. In the new directory you will find analbum.ymlfile and an emptyphotosdirectory.At this point, you should place some photos in thephotosdirectory
and set the title field of the album in thealbum.ymlfile. You can
also set the album date, the copyright line, and the filename of the
coverimage. Key/Value pairs you place under thepropertiesline will
be placed in the preamble of the markdown file, so you can use them in
Hugo layouts. For instance, you may want to add a country field, camera
details, etc.In the main directory (where thehugophotoswipe.ymlfile is), you can
now run:$ hps updateTo create the markdown file, the resized photos, and will update thealbum.ymlfile. HugoPhotoSwipe creates large and small photo sizes, as
well as thumbnails usingSmartCrop.py.If you now open thealbum.ymlfile, you'll notice that the fields for
the photos and the hashes have been extended. Underphotos:all the
photos in the directory will be listed, with for each photo afile,name,alt, andcaptionfield. The last three fields can be edited
by you. Doing this can be useful for SEO of your photos, but is not
required. Thehashesfield in thealbum.ymlfile is used to detect
changes in the photos, and don't need to be edited by you.Finally, if you want to regenerate all the markdown and resized photos,
you can always use:$ hps cleanto clean everything. This will of course not touch the original photo
files.NotesI've noticed that thumbnails are slightly nicer withSmartCrop.jsthan withSmartCrop.py. So, in thehugophotoswipe.ymlfile, you can set the optionuse_smartcrop_jstoTrueand thesmartcrop_js_pathto the path of thesmartcrop-cli.jsutility.
This ensures thumbnails are created with SmartCrop.js.HugoPhotoSwipe is free software, licensed under the GNU General Public
License, version 3 or later (GPLv3). Copyright G.J.J. van den Burg, all
rights reserved.If you find a problem or want to suggest a feature, please let me know by
opening an issue on GitHub. Don't hesitate, you're helping to make this
project better! If you prefer email, you can contact me atgertjanvandenburg  at gmail dot com.