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

Make a tool for adding canonical links to historical hexdocs #3865

Open
lpil opened this issue Nov 20, 2024 · 0 comments
Open

Make a tool for adding canonical links to historical hexdocs #3865

lpil opened this issue Nov 20, 2024 · 0 comments
Labels
help wanted Contributions encouraged priority:medium

Comments

@lpil
Copy link
Member

lpil commented Nov 20, 2024

Search engines are surfing links to outdated versions of package documentation. This is a problem as it misleads users, especially for core libraries such as the stdlib.

If the documentation had canonical links in the head element then search engines would hopefully suggest the current version instead.

<link rel="canonical" href="https://hexdocs.pm/package_name/path/to/file.html" />

#3864 covers adding the link to future releases, but we need to add it to historical releases too.

Make a Gleam program which given the name of a package:

  • Queries the hex API to get all the release version numbers
  • For each release
    • Downloads the docs tarball for each one (e.g. https://repo.hex.pm/docs/gleam_stdlib-0.17.1.tar.gz)
    • For each HTML page
      • Checks to see if the canonical link is in the HTML head
        • Leaves the HTML as-is if the link is present
        • Adds the link if it was absent
    • Creates a new tarball with the updated content
    • Uploads the new tarball to update the release's documentation

Making a tar library is probably the first step. It should protect against the security vulnerabilities of path traversal attacks and compression bombs.

@lpil lpil added help wanted Contributions encouraged priority:medium labels Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contributions encouraged priority:medium
Projects
None yet
Development

No branches or pull requests

1 participant