v0.24 - better redirects for multi-site setups
This release makes working with redirects in multi-site setups easier by adding more details. It:
- Exposes the
site
field. - Supports redirects without a
new_url
orpage
thus making HTTP 410 handling possible. - Returns one result per associated site.
Warning
This is a breaking change release.
- The
new_url
in results now takes into account theRedirect
site. Previously, this would always useBASE_URL
(from the settings file) - Redirects that apply to all sites (i.e. not associated with a specific
site
) now appear multiple times when querying - one for each Site created in Wagtail.
Upgrade considerations
In a multi-site setup, you should add the site
field to any redirect
queries to help disambiguate between redirects that apply to all sites.
For example, given we have two Sites created in Wagtail:
and a single Redirect from old-path
to new-path
that is not associated with any specific site (and thus applies to all sites).
Previously, querying for a redirect:
{
redirects {
newUrl
oldUrl
oldPath
page {
id
}
isPermanent
}
}
would produce:
{
"data": {
"redirects": [
{
"isPermanent": true,
"newUrl": "http://www.example.com/new-path",
"oldPath": "/old-path",
"oldUrl": "http://www.example.com/old-path",
"page": null
}
]
}
}
which excludes the redirect that applies to https://www.another-example.com.
As of this release, the same query would produce:
{
"data": {
"redirects": [
{
"isPermanent": true,
"newUrl": "http://www.example.com/new-path",
"oldPath": "/old-path",
"oldUrl": "http://www.example.com/old-path",
"page": null,
},
{
"isPermanent": true,
"newUrl": "http://www.another-example.com/new-path",
"oldPath": "/old-path",
"oldUrl": "http://www.another-example.com/old-path",
"page": null,
}
]
}
}
To disambiguate the results, you should add site
to your query, for example:
{
redirects {
newUrl
oldUrl
oldPath
page {
id
}
isPermanent
site {
hostname
}
}
}
which would return:
{
"data": {
"redirects": [
{
"isPermanent": true,
"newUrl": "http://www.example.com/new-path",
"oldPath": "/old-path",
"oldUrl": "http://www.example.com/old-path",
"page": null,
"site": {
"hostname": "www.example.com"
}
},
{
"isPermanent": true,
"newUrl": "http://www.another-example.com/new-path",
"oldPath": "/old-path",
"oldUrl": "http://www.another-example.com/old-path",
"page": null,
"site": {
"hostname": "www.another-example.com"
}
}
]
}
}
What's Changed
- Fixed test failing for wagtail 5.2 by @JakubMastalerz in #378
- Avoid using hardcoded localhost in Redirects by @JakubMastalerz in #380
New Contributors
- @JakubMastalerz made their first contribution in #378
Full Changelog: v0.23.0...v0.24.0