Skip to content
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

Add Sphinx redirects for latest pages #2266

Draft
wants to merge 5 commits into
base: devel
Choose a base branch
from

Conversation

oraNod
Copy link
Contributor

@oraNod oraNod commented Dec 6, 2024

Fixes #2147

This PR adds the Sphinx reredirects extension so that we can replace the latest redirects with something that is easier to maintain and provides a better user experience than stub pages.

For more detail, also see the conversation here: ansible/docsite#261 (comment)

Here are some comments about the files in the _data subdirectory:

I'm not sure if we really want to add those redirects to core docs but those are pages that were in core docs at some point and were moved. So it seems reasonable.

  • _data/plugins.yaml these are redirect rules for plugins/* pages from https://github.com/ansible/docsite/blob/main/ansible/11/.htaccess

  • _data/modules.yaml these are redirect rules for modules/* pages that come from the same .htaccess file as the plugins. Still need to go through and determine the best collection to use as the target redirect for most of these but it's not an impossible task. Rather than pointing to specific modules, I suggest we point to the main collection. This is in keeping with the effort to reduce maintenance burden for all these redirects.

  • data/deprecated_modules.yaml these are redirects for modules/* pages that have the deprecation notice. If / when these collections are removed, we can point to the docs.ansible.com/collections.html page.

@oraNod oraNod added DaWGs Good discussion item for the DaWGs doc builds Relates to building the documentation tooling This PR affects tooling (CI, pr_labeler, noxfile, linters, etc.) but not the docs builds themselves. labels Dec 6, 2024
with yaml_file.open(mode="r", encoding="utf-8") as f:
file_redirects = yaml.safe_load(f)
if file_redirects:
redirects.update(file_redirects)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I formatted the entire conf.py file, which might not be something we want to do for this PR because it makes it a little hard to see exactly what changed. I can revert that. Although I think formatting at some point would be a good idea.

Also not sure if this is too much cowbell or what. I mean initializing redirects and checking that things exist. Maybe this could be a lot simpler with fewer lines? I'd appreciate feedback on that please.

@oraNod oraNod requested a review from felixfontein December 6, 2024 12:45
@oraNod
Copy link
Contributor Author

oraNod commented Dec 6, 2024

@oraNod
Copy link
Contributor Author

oraNod commented Dec 6, 2024

Ran the package docs build workflow against this PR. Here is the run: https://github.com/ansible/ansible-documentation/actions/runs/12200497630

Generating the redirects doesn't appear to add to the build time (this is actually the second run).

Here are some pages that redirect:

I've checked the http status codes of all the pages (just the source pages, not the targets). I can see they're returning 200 instead of 301 or 302 but that's expected. As I mentioned elsewhere a 301 would be ideal for SEO but 200 is still much better than 404 and this is arguably a better user experience than redirecting to a single collections.html page.

I suppose a solution here could be to add all the generated source pages to a norobots.txt file so they don't get indexed. This would ensure that they don't cause the actual pages with content to be counted as duplicates.

Anyway here are the reports:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DaWGs Good discussion item for the DaWGs doc builds Relates to building the documentation tooling This PR affects tooling (CI, pr_labeler, noxfile, linters, etc.) but not the docs builds themselves.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using stub pages to replace redirects
1 participant