GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Centralize shared link definitions across MkDocs sites · Issue #20789 · pypi/warehouse

Centralize shared link definitions across MkDocs sites #20789

New issue
Copy link
New issue
Copy link
Open
Open
Centralize shared link definitions across MkDocs sites#20789
Copy link
Labels
documentation

Description

@nlhkabu
nlhkabu
opened on Oct 23, 2026
Issue body actions

Follow-up from @JacobCoffee's review on #20777 (#20777 (review)).

Problem

Our three MkDocs sites (user docs, dev docs, blog) use lots of inline [thing](https://...) links, and many of the same URLs are repeated across files. For example, https://docs.pypi.org/trusted-publishers/ appears 12 times and the api/json/ and api/index-api/ pages 6 times each.

So when a URL changes (as with the /help deprecation in #20777), we have to edit every occurrence. That makes for noisy diffs and harder reviews, and it's easy to miss one.

Proposal

Keep one shared file of reference-style link definitions and include it in every docs site, for example:

[pypi-2fa]: https://docs.pypi.org/your-account/two-factor-authentication/
[pypi-api-tokens]: https://docs.pypi.org/publishing/publishing-to-pypi/#using-an-api-token
[pypi-account-recovery]: https://docs.pypi.org/your-account/account-recovery/

Pages would then use reference links:

Enable [two-factor authentication][pypi-2fa].

A changed URL then needs one edit in one place, and the Markdown source is easier to read.

One possible approach is pymdownx.snippets with auto_append. It would append the shared links file to every page in mkdocs-user-docs.yml, mkdocs-dev-docs.yml and mkdocs-blog.yml. None of these configs enable snippets today.

Trade-offs / open questions

  • Readers of the raw Markdown have to look up where a reference points. The reviewer thinks this is worth it.
  • Naming convention for link keys (e.g. pypi-*, pug-* for packaging.python.org)
  • Should the blog be included? Old posts may intentionally link to URLs as they were at the time.
  • Can we catch undefined or unused references in CI? A dangling [text][ref] renders as literal text rather than failing the build.
  • Should we migrate existing links all at once, or gradually as files are touched?

Activity

  1. nlhkabu
    added
    documentation
    on Oct 23, 2026
  2. nlhkabu commented on Oct 23, 2026

    @nlhkabu
    nlhkabu
    on Oct 23, 2026
    ContributorAuthor
    More actions

    Note: this issue only covers links in docs - if we can, it would be great to solve this in a way that provides a solution for templates and views too

  3. nlhkabu commented on Oct 23, 2026

    @nlhkabu
    nlhkabu
    on Oct 23, 2026
    ContributorAuthor
    More actions

    Another place that would use this: the /help redirects in #20793.

    Browsers don't send #anchor to the server, so /help/ 301s to the docs homepage and docs/user/javascripts/help-redirects.js maps each old help anchor to its new docs page. That map is another 55 hardcoded docs URLs. If a heading is renamed, old /help/#... links quietly land at the top of the page instead (anchor validation is off in mkdocs-user-docs.yml).

    This leans towards a structured data file (YAML/JSON of named links) over pymdownx.snippets. The JS can't read Markdown link definitions, and neither can templates and views. With one data file:

    • the MkDocs hook could generate the reference links for docs pages
    • Warehouse could load it to back request.user_docs_url
    • the redirect map could become old anchor → link name, generated at build time
    • one CI check that every target exists in the built docs would cover docs, templates, views and redirects together
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentation

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.