Skip to content

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 10 commits into from
Feb 20, 2025

Conversation

Mpdreamz
Copy link
Member

@Mpdreamz Mpdreamz commented Feb 19, 2025

@Mpdreamz Mpdreamz self-assigned this Feb 19, 2025
@Mpdreamz Mpdreamz requested a review from a team February 19, 2025 21:23
@bmorelli25
Copy link
Member

bmorelli25 commented Feb 20, 2025

Thank you!

@colleenmcginnis / @shainaraskas / @lcawl — I could use some input on recommended functionality for handling redirects. I called one scenario in #552, but there are a few potential scenarios writers might face. I want to make sure we're picking the most critical to focus on. Here are the scenarios I'm thinking about:

Scenario 1: Moving a file
Goal: A writer moves a file to a new location.
Required functionality: A 1:1 redirect from the old file location to the new file location. All anchors in the old file are mapped to identical anchors in the new file.

Scenario 2: Splitting a page into multiple smaller pages
Goal: A writer breaks up an existing page into multiple pages.
Required functionality: A 1:many redirect, where the original file maps to multiple new pages. In this case, the anchors in the old file may end up in multiple new files. The ability to specify anchor-by-anchor redirects is required.

Scenario 3: Deleting a section on a page (removing anchors)
Goal: A writer removes a section of a page that was previously linked to via a cross-repo anchor link.
Required functionality: A 1:null mapping for anchors. Any inbound links with that anchor should update to point to the base page instead.

Scenario 4: Deleting an entire page
Goal: A writer removes a page completely.
Required functionality: A catchall redirect that strips any anchor links to the old page and points to a designated fallback page instead.

Thoughts? Do any additional scenarios or considerations come to mind? I think if we're able to at least address scenario 1, we'll be in a good state to move forward with the reference move on Monday.

@shainaraskas
Copy link
Contributor

shainaraskas commented Feb 20, 2025

@bmorelli25 another possible scenario: section moves

I'm not sure whether this would work in our current situation due to our shallow url structure, but if we need to relocate entire sections, we might want to be able to support redirects that use wildcards * for children

could string together two wildcards for complex scenarios:

old: /reference/fleet/*
new: /manage-data/ingest/fleet/*

old: /reference/fleet/reference-stuff/*
new: /reference/fleet/*

agree scenario 1 is all that's needed in the short term

@Mpdreamz Mpdreamz marked this pull request as ready for review February 20, 2025 14:26
@Mpdreamz
Copy link
Member Author

Thanks for those requirements @bmorelli25 I turned them in to tests and documentation here:

https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/556/contribute/redirects

All those scenarios are now fully supported and docs-builder now validates that the target files and anchors exists.

We also now read the redirects from a _?redirects.yml adjacent to _?docset.yml.

This should allow us to generate redirects using the mv command too (albeit naively just appending to the file). Will do so in a follow up.

@shainaraskas having glob redirects would be another great addition to minimize the config.

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.
Copy link
Contributor

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 🤷)

Suggested change
This allows you to publish your changes and work to update the other documentation sets.
This allows you to publish your changes and work to update the other documentation sets.
Redirects also allow any external links to our documentation impacted by a reorganization to resolve instead of returning a 404.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redirects also allow any external links to our documentation impacted by a reorganization to resolve instead of returning a 404.

This is not true yet, this currently only affects our link rewriting. We don't generate redirect mappings (yet).

Copy link
Contributor

@shainaraskas shainaraskas Feb 20, 2025

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

Copy link
Member

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.

@Mpdreamz Mpdreamz changed the title Add redirect information to docset.yml Add redirects.yml to publish renames/delations in links.json for dependent docsets. Feb 20, 2025
@bmorelli25 bmorelli25 merged commit 8d6c67a into main Feb 20, 2025
5 checks passed
@bmorelli25 bmorelli25 deleted the feature/redirect-config branch February 20, 2025 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants