Skip to main content

HugoPhotoSwipe

PyPI version

HugoPhotoSwipe is a command line application to easily create and manage PhotoSwipe albums when using the Hugo static website generator.

Useful links

Why?

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 post here for 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 Hugo shortcodes. These shortcode are then used to create the HTML code that PhotoSwipe needs. See the docs directory for the shortcodes.

Installation

HugoPhotoSwipe is available on PyPI, you can install it easily with pip:

$ pip install hugophotoswipe

After installation, you should have an hps command line program. Try running hps -V to check this.

Usage

This is a brief overview. See the Wiki for a full description.

Create a new directory for HugoPhotoSwipe and switch to it. For instance:

$ mkdir hugophotos
$ cd hugophotos

Next, initialize a HugoPhotoSwipe configuration with:

$ hps init

This creates a new HugoPhotoSwipe configuration file, called hugophotoswipe.yml. This is a YAML file. In this configuration file, you need to set at least the markdown_dir and output_dir variables. 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 the url_prefix variable, which is added before the path to the photo files.

Create a new album using:

$ hps new

HugoPhotoSwipe 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 an album.yml file and an empty photos directory.

At this point, you should place some photos in the photos directory and set the title field of the album in the album.yml file. You can also set the album date, the copyright line, and the filename of the coverimage. Key/Value pairs you place under the properties line 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 the hugophotoswipe.yml file is), you can now run:

$ hps update

To create the markdown file, the resized photos, and will update the album.yml file. HugoPhotoSwipe creates large and small photo sizes, as well as thumbnails using SmartCrop.py.

If you now open the album.yml file, you'll notice that the fields for the photos and the hashes have been extended. Under photos: all the photos in the directory will be listed, with for each photo a file, name, alt, and caption field. The last three fields can be edited by you. Doing this can be useful for SEO of your photos, but is not required. The hashes field in the album.yml file 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 clean

to clean everything. This will of course not touch the original photo files.

Notes

I've noticed that thumbnails are slightly nicer with SmartCrop.js than with SmartCrop.py. So, in the hugophotoswipe.yml file, you can set the option use_smartcrop_js to True and the smartcrop_js_path to the path of the smartcrop-cli.js utility. 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 at gertjanvandenburg at gmail dot com.

Metadata

Release files for hugophotoswipe 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hugophotoswipe 0.2.5
File Size Uploaded
hugophotoswipe-0.2.5.tar.gz 17.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hugophotoswipe 0.2.5
File Interpreter ABI Platform
hugophotoswipe-0.2.5-py3-none-any.whl Python 3 none any Details

Total release size: 46.2 kB

Release files / hugophotoswipe-0.2.5.tar.gz

Download URL hugophotoswipe-0.2.5.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
902f27e7a808b37b1a0cc93a6ad12387eb56f9afbe2ec9119d085d0e5aae944d
BLAKE2b-256 checksum
How to use checksums
f6480334172761a4f16a666eff6c82f76ec448cec57b93ac9f249c0fd45babcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/0.6.7 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

Release files / hugophotoswipe-0.2.5-py3-none-any.whl

Download URL hugophotoswipe-0.2.5-py3-none-any.whl
Size 29.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6d7f522769aca9101c619ce270793a031635209aa2bf8f8a9a1b8eedbed7828
BLAKE2b-256 checksum
How to use checksums
2cf3da4b5dd1e43353fe311e064200cf9889cd70f46f87ed8bbfa940814bd9a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/0.6.7 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

Release history Release notifications | RSS feed

0.3.1

2 release files

0.3.0

2 release files

This release

0.2.5 This release

2 release files

0.2.4

2 release files

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.16

1 release file

0.0.15

1 release file

0.0.14

1 release file

0.0.13

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page