Skip to main content

mkdocs-redirects

Plugin for mkdocs to create page redirects (e.g. for moved/renamed pages)

Initially developed by DataRobot.

PyPI License GitHub Workflow Status

Installing

Install with pip:

pip install mkdocs-redirects

Using

To use this plugin, specify your desired redirects in the plugin's redirect_maps setting in your mkdocs.yml:

plugins:
  - redirects:
      redirect_maps:
        'old.md': 'new.md'
        'old/file.md': 'new/file.md'
        'some_file.md': 'http://external.url.com/foobar'

Note
Don't forget that specifying the plugins setting will override the defaults if you didn't already have it set! See this page for more information.

The redirects map should take the form of a key/value pair:

  • The key of each redirect is the original markdown doc (relative to the docs_dir path).
    • This plugin will handle the filename resolution during the mkdocs build process. This should be set to what the original markdown doc's filename was (or what it would be if it existed), not the final HTML file rendered by MkDocs
  • The value is the redirect target. This can take the following forms:
    • Path of the markdown doc you wish to be redirected to (relative to docs_dir)
      • This plugin will handle the filename resolution during the mkdocs build process. This should be set to what the markdown doc's filename is, not the final HTML file rendered by MkDocs
    • External URL (e.g. http://example.com)

During the mkdocs build process, this plugin will create .html files in site_dir for each of the "old" file that redirects to the "new" path. It will produce a warning if any problems are encountered or of the redirect target doesn't actually exist (useful if you have strict: true set).

use_directory_urls

If you have use_directory_urls: true set (which is the default), this plugin will modify the redirect targets to the directory URL, not the actual index.html filename. However, it will create the index.html file for each target in the correct place so URL resolution works.

For example, a redirect map of 'old/dir/README.md': 'new/dir/README.md' will result in an HTML file created at $site_dir/old/dir/index.html which redirects to ../../new/dir/.

Additionally, a redirect map of 'old/dir/doc_name.md': 'new/dir/doc_name.md' will result in $site_dir/old/dir/doc_name/index.html redirecting to ../../new/dir/doc_name/.

This mimics the behavior of how MkDocs builds the site dir without this plugin.

Developing

Dev dependencies and tasks are managed with Hatch. Tasks run in their own environment, created on the fly if missing, in a separate directory tree.

To run all checks and fixes:

hatch run all

You can learn about individual commands from the output, or by inspecting scripts in pyproject.toml.

Releasing

A release is published to PyPI through GitHub Actions whenever a new tag is pushed.

So, to create a release, run .tools/release.sh x.y.z (which bumps the version in __init__.py, checks the build, creates a commit and a tag vx.y.z, and pushes it to GitHub).

Then fill out a GitHub release with release notes.

Metadata

Release files for mkdocs-redirects 1.2.3

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

Source distribution (sdist)

Source distribution for mkdocs-redirects 1.2.3
File Size Uploaded
mkdocs_redirects-1.2.3.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-redirects 1.2.3
File Interpreter ABI Platform
mkdocs_redirects-1.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 14.0 kB

Release files / mkdocs_redirects-1.2.3.tar.gz

Download URL mkdocs_redirects-1.2.3.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5e980330999299729a2d6a125347d1af78023d68a23681a4de3053ce7dfe2e51
BLAKE2b-256 checksum
How to use checksums
732549725f78ca5d3026b09973f7a2b3a8b179cc2e8c15e43d5a13bc79f6b274
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 Mar 28, 2026.

Transparency log

Release files / mkdocs_redirects-1.2.3-py3-none-any.whl

Download URL mkdocs_redirects-1.2.3-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec7312fff462d03ec16395d0c001006a418f8d0c21cdf2b47ff11cf839dc3ce0
BLAKE2b-256 checksum
How to use checksums
c690871b1cddc01d2ba1637b858eeeabc2e3013dc8df591306b5567b98ef0870
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 Mar 28, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.3 This release

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

1 release file

1.1.0

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.0.6

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