|
| 1 | +.. post:: January 3, 2024 |
| 2 | + :tags: redirects, docs |
| 3 | + :category: Changelog |
| 4 | + :author: Santos |
| 5 | + :location: CUE |
| 6 | + |
| 7 | +New improvements to redirects |
| 8 | +============================= |
| 9 | + |
| 10 | +As your documentation evolves, content is moved, and pages are renamed, |
| 11 | +leading to broken links for your users. |
| 12 | +Redirects allow you to point users to the new location of a page. |
| 13 | + |
| 14 | +We are excited to announce significant improvements to our redirects feature to make them more flexible and powerful. |
| 15 | + |
| 16 | +Key improvements |
| 17 | +---------------- |
| 18 | + |
| 19 | +HTTP status code |
| 20 | + You can now choose the `HTTP status code`_ for your redirects, |
| 21 | + selecting between 301 (permanent redirect) and 302 (temporary redirect). |
| 22 | + Previously, all redirects had the status code 302. |
| 23 | + |
| 24 | +.. _HTTP status code: https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections |
| 25 | + |
| 26 | +Explicit ordering |
| 27 | + Redirects now have an explicit order, |
| 28 | + allowing you to control the order in which they are processed. |
| 29 | + Previously, redirects were ordered based on their last modification date. |
| 30 | + |
| 31 | +Disable redirects without deletion |
| 32 | + You can now disable redirects without deleting them. |
| 33 | + This is useful when debugging or when you want to temporarily disable a redirect. |
| 34 | + |
| 35 | +Trailing slash |
| 36 | + Redirects now apply to URLs with and without a trailing slash. |
| 37 | + Previously, you had to create two redirects to handle both cases. |
| 38 | + |
| 39 | +Suffix wildcards |
| 40 | + While we already supported suffix wildcard redirects, their functionality was limited. |
| 41 | + Now wildcard redirects use a more familiar syntax, ``*`` instead of ``$rest``, |
| 42 | + and the ``:splat`` placeholder is available in the target URL. |
| 43 | + Wildcards can be used with *Exact* and *Page* redirects. |
| 44 | + |
| 45 | +Other changes |
| 46 | +------------- |
| 47 | + |
| 48 | +- Redirects aren't processed in domains from pull requests previews. |
| 49 | + You should treat these domains as ephemeral and not rely on them for user-facing content. |
| 50 | +- Redirects now have a description field, allowing you to provide additional information about the redirect. |
| 51 | +- *Sphinx HTMLDir -> HTML* and *Sphinx HTML -> HTMLDir** redirects where renamed to *Clean URL to HTML* and *HTML to Clean URL* redirects. |
| 52 | + These types of redirects are valid for all documentation tools, not just Sphinx. |
| 53 | +- Prefix redirects were removed. |
| 54 | + The same functionality can be achieved with an *Exact* redirect using a wildcard. |
| 55 | + |
| 56 | +For more details and examples, refer to `our documentation`_. |
| 57 | + |
| 58 | +.. _our documentation: https://docs.readthedocs.io/en/stable/user-defined-redirects.html#user-defined-redirects |
| 59 | + |
| 60 | +Breaking changes |
| 61 | +---------------- |
| 62 | + |
| 63 | +In order to support these new improvements, we have made some breaking changes: |
| 64 | + |
| 65 | +- The old ``$rest`` syntax for wildcard redirects is no longer supported. |
| 66 | + Use ``*`` instead. |
| 67 | +- When using a wildcard, the matched suffix is no longer added to the target URL automatically. |
| 68 | + Use the ``:splat`` placeholder in the target URL to add the matched suffix. |
| 69 | +- The redirect type ``sphinx_html`` used in the API was renamed to ``clean_url_to_html``. |
| 70 | +- The redirect type ``sphinx_htmldir`` used in the API was renamed to ``html_to_clean_url``. |
| 71 | +- The prefix redirect type was removed. |
| 72 | + Use an *Exact* redirect with a wildcard instead. |
| 73 | + |
| 74 | +If you had redirects using the old syntax, you don't need to do anything. |
| 75 | +We have automatically migrated them to use the new syntax. |
0 commit comments