Create anchor redirects

Published on

Sometimes a page using anchors to link to content on the same page grows to an extent where it makes sense to extract that content to new pages.

To keep the potentially shared anchor links working, you can redirect previously used anchors to new pages.

Add an anchorRedirects key to the page's front matter—the YAML block between --- lines at the start of .md file. This key can list multiple redirects and works both for fully qualified URLs and local paths:

anchorRedirects:
your-old-anchor: https://your-new-fully-qualified-page-url.com/with/optional/path/#and-optional-new-anchor
your-old-anchor-2: /local/path/#with-an-optional-new-anchor

Where your-old-anchor is the fragment identifier without #.

For example, in the /docs/devtools/recorder/index.md file:

anchorRedirects:
selector: /docs/devtools/recorder/reference/#selector

This redirects:

  • From https://developer.chrome.com/docs/devtools/recorder/#selector
  • To https://developer.chrome.com/docs/devtools/recorder/reference/#selector

Published on Improve article

This site uses cookies to deliver and enhance the quality of its services and to analyze traffic. If you agree, cookies are also used to serve advertising and to personalize the content and advertisements that you see. Learn more about our use of cookies.