Contents

Redirected

A directive that specifies a previous URL for the page where the directive appears.

Declaration

@Redirected(from: URL)

Parameters

  • from:

    The URL that redirects to the page associated with the directive. (required)

Overview

If the page has moved more than once you can add multiple Redirected directives, each specifying one previous URL. For example:

@Redirected(from: "old/path/to/this/page")
@Redirected(from: "another/old/path/to/this/page")

Setting up Redirects

If you host your documentation on a web server, you can set a HTTP “301 Moved Permanently” redirect for each Redirected value to avoid breaking existing links to your content.

To find each page’s Redirected values, pass the --emit-digest flag to DocC. This flag configures DocC to write additional metadata files to the output directory. One of these files, linkable-entities.json, contains summarized information about all pages and on-page landmarks that you can link to from outside the DocC documentation. Each of these “entities” has a "path"—which represents the current relative path of that page—and an optional list of "redirects"—which represent all the Redirected values for page as they were authored in the markup. You can write either relative redirect values or absolute redirect values in the markup depending on what information you need when setting up HTTP “301 Moved Permanently” redirects on your web server.

See Also

Configuring Documentation Behavior