Configure redirects for a Datasette instance
Install this plugin in the same environment as Datasette.
datasette install datasette-redirectsConfigure redirects in your datasette.yaml configuration file. Redirects are organized by HTTP status code:
plugins:
datasette-redirects:
301:
old-page: https://example.com/new-page
another-old-page: /new-location
302:
temporary-page: /temporary-locationThis configuration will:
- Redirect
/old-pagetohttps://example.com/new-pagewith a 301 (permanent) status - Redirect
/another-old-pageto/new-locationwith a 301 status - Redirect
/temporary-pageto/temporary-locationwith a 302 (temporary) status
Both /path and /path/ variants are matched automatically - you don't need to configure both.
To set up this plugin locally, first checkout the code. You can confirm it is available like this:
cd datasette-redirects
# Confirm the plugin is visible
uv run datasette pluginsTo run the tests:
uv run pytest