A Lektor plugin to help with generating redirects for, e.g., moved pages.
Project description
lektor-redirect
This plugin allows pages to specify alternative/old URLs which should redirect to their current location.
How it works
There are two ways that redirects may be implemented by this plugin. Either or both may be enabled.
Redirect pages
Redirect pages can be generated at the specified URLs. The template for these pages is up to you, however the intent is that these pages will attempt an meta refresh and/or javascript redirect to the target page.
Redirect map
A redirect map file can be generated. This may be used to configure your webserver to issue the desired redirects itself. (Currently only an nginx-style map is supported.)
Usage
By default the plugin looks for a field named redirect_from
on pages in the
site. This field should contain a sequence of URLs to redirect from — most
likely it should have a field type of strings
.
The URLs in the redirect_from
field may either be absolute (beginning)
with a slash (these are interpreted relative to the root of the site) or
they may be relative, in which case they are interpreted relative to the
URL of the parent of the page containing the redirect_from
field.
As an example, if the is a page at lektor path /blog/first-post
, who’s
URL, if nothing exotic is done with slug configuration is /blog/first-post/
,
then, if first-posts
’s redirect_from
is set to test-post
, there will
be a redirect generated in /blog/test-post/index.html
which will hopefully
redirect the user to '/blog/first-post/'.
Configuration
The plugin looks for configuration in it’s plugin config file:
configs/redirect.ini
. Settings should be in a [redirect]
section.
There are currently to configurable settings. Here are the defaults:
[redirect]
template = template.html
redirect_from_field = redirect_from
Caveats
Currently this plugin will not work on Lektor sites with alts enableds.
Author
Jeff Dairiki dairiki@dairiki.org
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for lektor_redirect-0.1.0b1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ff3002e009b94c588893c771b8bc1803773177ac9647c184e1b5fa0d7f8ae50 |
|
MD5 | 6645c9d629b9db62e3a6be6e48f9799e |
|
BLAKE2b-256 | 8c14d455a9bb7b62094fc5d4fcc76293e57923d9745abfe979a6b405d88d958e |