Set Up URL Redirects with page-aliases
You can create a redirect using Antora’s built-in
This page attribute is useful when you delete a page, rename a page’s file, or move a page to a different module or component.
Bulk URL RedirectsThe
page-aliases attribute is set in the page header of a target page using an attribute entry.
The target page refers to the page you’re redirecting a source page to.
The source page refers to the deleted, renamed, or moved page that you’re redirecting from.
A source page’s page ID—its page ID before it was deleted, renamed, or moved—is assigned to the
page-aliases attribute in a target page.
Multiple page IDs can be assigned to the attribute in a comma-separated list.
= Title of Target Page :page-aliases: source-page-filename.adoc, version@component:module:source-page-filename.adoc
Antora calculates the URL for a source page’s page ID and generates redirect information so that the source page URL redirects to the target page URL.
Any coordinates, such as version or component, that aren’t specified in a page ID assigned to
page-aliases are interpolated from the target page’s coordinates.
The generated output format of the redirect information is determined by your chosen redirect facility.
A page ID assigned to a
page-aliases attribute can be used in an xref.
Therefore, if you delete, rename, or move a page, you don’t need to update any references to it in your source files.
page-aliases attribute can only be applied to pages.
Partials, examples, images, and attachments can’t be aliased.
While a page ID assigned to
page-aliases works in xrefs, the page version selector in the reference UI does not connect previous versions of the source page to the target page.
If you change a source page’s filename from old-name.adoc to new-name.adoc, assign the file’s former page ID to
page-aliases in its header.
= Title of Target Page :page-aliases: old-name.adoc
This will result in https://base-url.com/component/version/module/old-name.html being redirected to https://base-url.com/component/version/module/new-name.html.
The version, component, and module coordinates that weren’t specified in the
old-name.adoc page ID are interpolated from the target page’s coordinates.
Alternatively, if you’ve specified
indexify in your playbook, https://base-url.com/component/version/module/old-name will redirect to https://base-url.com/component/version/module/new-name .
When a page is moved from one module to another module in the same component, the aliased page ID needs to contain the source page’s former module coordinate.
In Example 3, the page
source-1.adoc has moved from
module-z are modules in version
= Title of Target Page :page-aliases: module-1:source-1.adoc (1)
|1||Specify the former module coordinate in addition to the page coordinate when moving a page to another module.|
Now, Antora will redirect the URL https://base-url.com/component-1/5.0/module-1/source-1.html to the URL https://base-url.com/component-1/5.0/module-z/source-1.html.
When a page is moved from one component to another component, assign the source page’s fully qualified former page ID to
In Example 4, the page
source-w.adoc has moved from version
module-u to version
= Title of Target Page :page-aliases: 1.4@component-8:module-u:source-w.adoc
This will result in the URL https://base-url.com/component-8/1.4/module-u/source-w.html being redirected to https://base-url.com/component-delta/3.0/source-w.html.
Sometimes you just need to delete a page. Before redirecting the deleted page’s URL to another page, consider the following:
Is there a potential target page that would help the visitors who previously used the information on the deleted page? For instance, the deleted page described feature A, but feature A has been deprecated; users of feature A should now migrate to feature B.
Is the deleted page a high traffic page? If so, is there a relevant page that would definitely assist the people looking for the deleted page?
You shouldn’t create a redirect to a target page that doesn’t have much in common with the deleted page, as this often frustrates visitors.
If it’s appropriate to redirect the deleted page’s URL to another page, assign the deleted page’s ID to the
page-aliases attribute, making sure to specify the necessary coordinates.
= Title of Target Page :page-aliases: source-page-filename.adoc
|It creates a bad user experience (and is a bad SEO practice), to just redirect deleted pages to the site’s home page or a project’s start page. This policy confuses visitors because they may not realize the page they’re looking for no longer exists. In cases where there isn’t a highly relevant target page to redirect the deleted page to, it’s better to direct visitors to a custom 404 page.|