Skip to main content

nginx_alias_map: A Plugin for Pelican

Build Status PyPI Version License

This Pelican plugin creates an nginx-compatible map between the final page locations and prior locations, defined in the "Alias" attribute for any article or page.

Loosely based on pelican-alias by Chris Williams, which itself was inspired by jekyll_alias_generator.

Installation

This plugin can be installed via:

python -m pip install pelican-nginx-alias-map

Usage

Add the directory to the base plugins directory to PLUGIN_PATHS in pelicanconf.py, and then add nginx_alias_map to the PLUGINS list. For example,

PLUGIN_PATHS = ["plugins"]
PLUGINS = ['nginx_alias_map']

Definable parameters (with defaults in brackets) allow some configuration of the output of the plugin.

There are two definable parameters, one from Chris's code (ALIAS_DELIMITER), which defines the delimiter for multiple aliases for the same item; and ALIAS_FILE, which defines the final name of the output file containing the map; and

ALIAS_DELIMITER : Delimeter between multiple aliases for the same item [","]
ALIAS_FILE : Name of map file to be placed in `output` ['alias_map.txt']
ALIAS_MAP : Name of the map used in the alias file ['redirect_uri']
ALIAS_MAP_TEMP: Name of the map used in the alias file when 2-stage lookup is needed ['redirect_uri_1']

Support for URLs with query strings

In the event that you need to redirect a URI that contains a query string, a separate map block will be created to map the $request_uri against an re.escaped version of your alias that contains the ? character. Otherwise, when no query string is present, the test is made against $uri, which has much more processing done with it (query string removal, removal of unnecessary '/'s, and so forth).

NGINX configuration

The resulting file (stored in output/$(ALIAS_FILE)) is ready to be included into your nginx configuration file (in an http stanza). Once the map is created, use the ALIAS_MAP variable in your processing.

include /opt/web/output/alias_map.txt;

server {
  listen       *:80 ssl;
  server_name  example.server;


    # Redirection logic
    if ( $redirect_uri ) {
        return 301 $redirect_uri;
    }

    location / {
        alias /opt/web/output;
    }
}

This configuration uses the evil if statement, but it's concise. If you have a better approach, please create a pull request, and I'll add it to this doc (or replace it if it makes more sense).

I've chosen to use a 301 redirect here, because I'm confident of the permanency. During testing, you may want to use a 302.

Contributing

Contributions are welcome and much appreciated. Every little bit helps. You can contribute by improving the documentation, adding missing features, and fixing bugs. You can also help out by reviewing and commenting on existing issues.

To start contributing to this plugin, review the Contributing to Pelican documentation, beginning with the Contributing Code section.

Updating

We use dependabot for updating dependencies, conventional commits for commit messages, and github actions for release.

To generate a release:

  1. cz bump --dry-run [--increment patch] to verify changes
  2. cz bump [--increment patch] to finalize
  3. git push to send code and git push <tag> to send the tag (or the less-safe --tags)

License

This project is licensed under the MIT license.

Metadata

Release files for pelican-nginx-alias-map 2.0.6

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

Source distribution (sdist)

Source distribution for pelican-nginx-alias-map 2.0.6
File Size Uploaded
pelican_nginx_alias_map-2.0.6.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pelican-nginx-alias-map 2.0.6
File Interpreter ABI Platform
pelican_nginx_alias_map-2.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 13.3 kB

Release files / pelican_nginx_alias_map-2.0.6.tar.gz

Download URL pelican_nginx_alias_map-2.0.6.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
06b8c3066d9cdc6800cd5fc60a2efaf47d3d961d93a13f88aecaacc9e4a01f45
BLAKE2b-256 checksum
How to use checksums
2cd8db43b2119de0677355dcab41a84bc32cbf52f502dff5f807e8c5e270ec24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2025.

Transparency log

Release files / pelican_nginx_alias_map-2.0.6-py3-none-any.whl

Download URL pelican_nginx_alias_map-2.0.6-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f0b7adbc1395ce9a4688c820b4a884451ca7c95fee42b52fa7dbd6f3f2fbaedc
BLAKE2b-256 checksum
How to use checksums
e14c22b104f8cea11ed00f5579066de3fbe0112b06f90f8b37391dfcd0f69124
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

2.0.6 This release

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

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