Configuring redirects
If an article's title, version, or location changes, you can create a redirect to the current content.
About redirects
If a change is made to an article that affects people's ability to find it, we create a redirect from any outdated versions to the current content. We might need to do this if an article's title is changed, a new version is added, or the location of the file is changed.
Redirects can be configured locally or externally.
Configuring local redirects
Within the GitHub Docs, you can redirect from one file to another or from one version to another.
Redirects across files
If you change the name of an article and want its old URL to redirect to its new URL for all versions, use theredirect_from
frontmatter with the path to the article's old name. If you change the name of an article and want different versions to redirect to different URLs, follow the steps in theRedirects across versions section.
In the following example, the article "All about commits" was renamed to "Creating your first commit." Theredirect_from
frontmatter redirects anyone who navigates to the old article URL to the new article URL.
title:Creatingyourfirstcommitredirect_from:-/content/get-started/all-about-commits
Seeredirect_from
in the GitHub Docs README file for more details.
Automatic redirects for URLs that do not include a version
If a URL for a page is entered without a version (https://docs.github.com/ARTICLE
instead ofhttps://docs.github.com/VERSION/ARTICLE
), the site will automatically redirect it to the first available version of the page.
The order of precedence is specified inlib/all-versions.ts
. The current order of precedence is:
- GitHub Free, GitHub Pro, or GitHub Team (
fpt
) - GitHub Enterprise Cloud (
ghec
) - GitHub Enterprise Server (
ghes
)
If a page titledARTICLE
is only available in GitHub Enterprise Cloud and GitHub Enterprise Server, the linkhttps://docs.github.com/ARTICLE
will automatically redirect tohttps://docs.github.com/enterprise-cloud@latest/ARTICLE
because GitHub Enterprise Cloud has precedence over GitHub Enterprise Server.
IfARTICLE
is available in Free, Pro, or Team, no redirect will occur becausefpt
pages do not have a version segment, so thefpt
content athttps://docs.github.com/ARTICLE
will render.
Redirects across versions
If you want the URL for one version of an article to redirect to a URL for another version or to another URL entirely, you must update theredirect-exceptions.txt file in thesrc/redirects
directory.
For example, if you remove the Free, Pro, or Team (fpt
) version of an article, the URL will automatically redirect to the next available version of the page. If you want it to redirect to a version that is lower in the order of precedence, or to a different page entirely, you must specify an exception.
Each entry in theredirect-exceptions
file should start with the path you want to redirectto, including the version, followed by an unordered list of the paths you want to redirectfrom. In the following example, the paths in the unordered list will redirect to the GitHub Enterprise Cloud version ofExporting member information for your organization.
/enterprise-cloud@latest/organizations/managing-membership-in-your-organization/exporting-member-information-for-your-organization - /enterprise-server@3.3/organizations/managing-membership-in-your-organization/exporting-member-information-for-your-organization - /enterprise-server@3.4/organizations/managing-membership-in-your-organization/exporting-member-information-for-your-organization - /enterprise-server@3.5/organizations/managing-membership-in-your-organization/exporting-member-information-for-your-organization
Configuring external redirects
Rarely, content will move outside the GitHub Docs site. For these types of redirects, update theexternal-sites.json
file in thesrc/redirects
directory.
Each entry in theexternal-sites.json
file is a key value pair where the key is the path to where the content was and the value is the path to where it should redirect.
"/github-status":"https://www.githubstatus.com/","/articles/github-security":"https://github.com/security",