Skip to main content

Manage redirects in the ReadTheDocs admin, programmatically

Project description

Manage redirects in the ReadTheDocs admin, programmatically. Addressing the rtfd/readthedocs.org#2904 issue.

Installation

Requires Python 3.6 and higher.

$ pip install rtd-redirects

Usage

$ rtd-redirects project-name ./redirects.yml --username=honzajavorek

Uploads redirects defined in the redirects.yml file to ReadTheDocs redirects administration of the project-name project.

The tool uses ReadTheDocs’ HTML interface (there’s no official API for redirects), so you need to provide your username and password. HTTPS is used to transfer the credentials to ReadTheDocs.

rtd-redirects tries to be idempotent, i.e. you can run it several times in row and it should always end with the same results. If there are any redirects with the same source path, the tool will replace them with whatever is defined in the redirects.yml file. Existing redirects which do not collide with contents of redirects.yml won’t be affected.

redirects.yml

Only page redirects are supported at the moment. The format of the file is as follows:

redirects:
  # we've migrated from MkDocs to Sphinx
  "/example/": "/example.html"
  "/python/": "/python.html"

  # page removed in favor of section
  "/green.html": "/colors.html#green"

  # only for convenience
  "/praha.html": "/prague.html"

Why YAML? Because it’s easy to read by humans, easy to write by humans, and above all, it has support for comments. Redirects are corrections and you should document why they’re necessary.

Usage with ReadTheDocs PRO

If you are using a commercial edition of the RTD (from readthedocs.com instead of readthedocs.org), please specify --pro flag in the command, like this

$ rtd-redirects project-name ./redirects.yml --username=honzajavorek --pro

There is also an opposite flag --free which is added by default, so can be omitted

License: MIT

© 2017-? Honza Javorek mail@honzajavorek.cz

This work is licensed under MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rtd-redirects-1.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

rtd_redirects-1.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file rtd-redirects-1.1.0.tar.gz.

File metadata

  • Download URL: rtd-redirects-1.1.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.3 CPython/3.8.6 Darwin/18.7.0

File hashes

Hashes for rtd-redirects-1.1.0.tar.gz
Algorithm Hash digest
SHA256 4a1f3c74c4315c85651c7814b00940292024338478d26dc919ad3b551e461a05
MD5 78c944e7496e2dfa838c91a4f290f03d
BLAKE2b-256 f7f4ecad9c433db5908de3a398edad2cc1fd152f01c3518e7b3f846d997aeeaa

See more details on using hashes here.

File details

Details for the file rtd_redirects-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: rtd_redirects-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.3 CPython/3.8.6 Darwin/18.7.0

File hashes

Hashes for rtd_redirects-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b6a955bbbb12ae565a752ddef0ae068bf8d5c32affde844020523300ecaa8c3
MD5 70c48c8b4ecb1112b1d9c2e0e9c69746
BLAKE2b-256 077e8b8c36c38c21fc5a32290ec578edfe9d272b296d91932f9a5738295cc694

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page