-
Notifications
You must be signed in to change notification settings - Fork 18
Add redirects.yml to publish renames/delations in links.json for dependent docsets. #556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
95accc6
Add redirect information to docset.yml
Mpdreamz e771c62
Support all scenarios
Mpdreamz 873f63d
add documentation for redirects
Mpdreamz 6a3152b
move redirects to separate file
Mpdreamz ccc2b99
add target validation for redirect files and anchors
Mpdreamz d57a8ef
Merge remote-tracking branch 'origin/main' into feature/redirect-config
Mpdreamz b785dea
fix accidental touch of pages-nav.ts
Mpdreamz 17d37b7
fix failing testS
Mpdreamz 090834b
update tests to use real redirect and anchor page data
Mpdreamz 51a6d1e
Update docs/contribute/redirects.md
Mpdreamz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
redirects: | ||
'testing/redirects/4th-page.md': 'testing/redirects/5th-page.md' | ||
'testing/redirects/9th-page.md': '!testing/redirects/5th-page.md' | ||
'testing/redirects/6th-page.md': | ||
'testing/redirects/7th-page.md': | ||
to: 'testing/redirects/5th-page.md' | ||
anchors: '!' | ||
'testing/redirects/first-page-old.md': | ||
to: 'testing/redirects/second-page.md' | ||
anchors: | ||
'old-anchor': 'active-anchor' | ||
'removed-anchor': | ||
'testing/redirects/second-page-old.md': | ||
many: | ||
- to: "testing/redirects/second-page.md" | ||
anchors: | ||
"aa": "zz" | ||
"removed-anchor": | ||
- to: "testing/redirects/third-page.md" | ||
anchors: | ||
"yy": "bb" | ||
'testing/redirects/third-page.md': | ||
anchors: | ||
'removed-anchor': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
--- | ||
navigation_title: "Redirects" | ||
--- | ||
# Adding redirects to link resolving | ||
|
||
If you [move files around](move.md) or simply need to delete a few pages you might end up in a chicken-and-egg situation. The files you move or delete might still be linked to by other [documentation sets](../configure/content-set/index.md). | ||
|
||
Redirects allow you to force other documentation sets to resolve old links to their new location. | ||
This allows you to publish your changes and work to update the other documentation sets. | ||
|
||
## File location. | ||
|
||
The file should be located next to your `docset.yml` file | ||
|
||
* `redirects.yml` if you use `docset.yml` | ||
* `_redirects.yml` if you use `_docset.yml` | ||
|
||
## Syntax | ||
|
||
A full overview of the syntax, don't worry we'll zoom after! | ||
|
||
```yaml | ||
redirects: | ||
'testing/redirects/4th-page.md': 'testing/redirects/5th-page.md' | ||
'testing/redirects/9th-page.md': '!testing/redirects/5th-page.md' | ||
'testing/redirects/6th-page.md': | ||
'testing/redirects/7th-page.md': | ||
to: 'testing/redirects/5th-page.md' | ||
anchors: '!' | ||
'testing/redirects/first-page-old.md': | ||
to: 'testing/redirects/second-page.md' | ||
anchors: | ||
'old-anchor': 'active-anchor' | ||
'removed-anchor': | ||
'testing/redirects/second-page-old.md': | ||
many: | ||
- to: "testing/redirects/second-page.md" | ||
anchors: | ||
"aa": "zz" | ||
"removed-anchor": | ||
- to: "testing/redirects/third-page.md" | ||
anchors: | ||
"bb": "yy" | ||
'testing/redirects/third-page.md': | ||
anchors: | ||
'removed-anchor': | ||
``` | ||
|
||
### Redirect preserving all anchors | ||
|
||
This will rewrite `4th-page.md#anchor` to `5th-page#anchor` while still validating the | ||
anchor is valid like normal. | ||
|
||
```yaml | ||
redirects: | ||
'testing/redirects/4th-page.md': 'testing/redirects/5th-page.md' | ||
``` | ||
### Redirect stripping all anchors | ||
|
||
Here both `9th-page.md` and `7th-page.md` redirect to `5th-page.md` but the crosslink resolver | ||
will strip any anchors on `9th-page.md` and `7th-page.md`. | ||
|
||
:::{note} | ||
The following two are equivalent. The `!` prefix provides a convenient shortcut | ||
::: | ||
|
||
```yaml | ||
redirects: | ||
'testing/redirects/9th-page.md': '!testing/redirects/5th-page.md' | ||
'testing/redirects/7th-page.md': | ||
to: 'testing/redirects/5th-page.md' | ||
anchors: '!' | ||
``` | ||
|
||
A special case is redirecting to the page itself when a section gets removed/renamed. | ||
In which case `to:` can simply be omitted | ||
|
||
```yaml | ||
'testing/redirects/third-page.md': | ||
anchors: | ||
'removed-anchor': | ||
``` | ||
|
||
### Redirect renaming anchors | ||
|
||
* `first-page-old.md#old-anchor` will redirect to `second-page.md#active-anchor` | ||
* `first-page-old.md#removed-anchor` will redirect to `second-page.md` | ||
|
||
Any anchor not listed will be forwarded and validated e.g; | ||
|
||
* `first-page-old.md#another-anchor` will redirect to `second-page.md#another-anchor` and validate | ||
`another-anchor` exists in `second-page.md` | ||
|
||
```yaml | ||
redirects: | ||
'testing/redirects/first-page-old.md': | ||
to: 'testing/redirects/second-page.md' | ||
anchors: | ||
'old-anchor': 'active-anchor' | ||
'removed-anchor': | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This acts as a redirect target | ||
|
||
|
||
## Another anchor [bb] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This is 1 redirecting to 2 | ||
|
||
|
||
1 is redirecting to 2 | ||
|
||
|
||
## Has an anchor as well |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This is 2 redirecting to 1 | ||
|
||
|
||
2 is redirecting to 1 | ||
|
||
|
||
## A different anchor [active-anchor] | ||
|
||
## Anchor ZZ [zz] | ||
|
||
Some content | ||
|
||
## Anchor YY [yy] | ||
|
||
Some content |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This acts as a redirect target | ||
|
||
|
||
## Another anchor [bb] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assume this will also just add normal redirect functionality (sorry for the worst sentence ever 🤷)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not true yet, this currently only affects our link rewriting. We don't generate redirect mappings (yet).
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might want to say this in a note - that the redirects won't resolve for now but will in future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that we should note this. I'll add in a follow-up PR so we can get this merged.