Skip to main content

MkDocs plugin: rewrite ../ markdown links (inline and reference-style) to forge view URLs in built HTML

Project description

MkDocs Source Links

OpenSSF Best Practices OpenSSF Baseline OpenSSF Scorecard SLSA 3 PyPI License: MIT CI codecov python uv ruff mypy pre-commit

MkDocs plugin that rewrites ](../path) links to your git forge in built HTML only. Source markdown keeps relative paths so GitHub and your IDE still work.

  • Fileshttps://…/blob/<ref>/<path> (GitHub/GitLab; forge-specific paths on Gitea, Bitbucket, Azure)
  • Directorieshttps://…/tree/<ref>/<path> where the forge distinguishes files from directories
  • Pin ref: pin: branch (default), pin: commit (HEAD SHA), or pin: tag (exact tag at HEAD; Gitea uses /src/tag/…, Azure uses GT…)
  • Forges: GitHub, GitLab, Bitbucket Cloud, Gitea/Forgejo, Azure DevOps (autodetected; self-hosted via forge:)

Documentation: https://filipchristiansen.github.io/mkdocs-source-links/

Install

pip install mkdocs-source-links

Usage

site_name: My project
repo_url: https://github.com/you/your-repo
edit_uri: edit/main/docs/

plugins:
  - source-links

Requires repo_url in mkdocs.yml (shown above). Without it, links are left unchanged.

Optional branch override:

plugins:
  - source-links:
      branch: develop

Advanced options

plugins:
  - source-links:
      pin: commit             # embed HEAD SHA instead of branch name
      # pin: tag              # exact tag at HEAD (release builds); else resolved branch
      forge: gitlab           # override autodetection for custom domains
      warn_on_missing: false  # silence missing-target warnings
      enabled: !ENV [SOURCE_LINKS, true]  # disable per environment

Line fragments in links (#L10, #L10-L20) are translated to each forge's line-reference syntax. See the configuration docs for all options.

Link conventions and branch resolution

Parent-directory links (../path) to repo files and directories are rewritten to forge blob/tree URLs; links between pages inside docs/ are unchanged. Branch names are resolved from plugin config, extra.git_branch, or edit_uri.

See Usage and Configuration in the docs for the full tables and resolution order.

Contributing

This project uses uv, pre-commit, and a Makefile.

make install   # install Python 3.10, sync all groups, set up pre-commit hooks
make ci        # run the full pre-PR suite: lint, test, coverage

Maintainers release with make release-prep VERSION=X.Y.Z (bump, roll the hand-written CHANGELOG.md, open the release PR) and, once merged, make release-tag VERSION=X.Y.Z (signed tag and publish to PyPI).

See Contributing for the full workflow and Changelog for release notes. Further reading: Governance, Roadmap, Support, Code of conduct, Maintainers, Security policy, and Release verification.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs_source_links-0.5.1.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocs_source_links-0.5.1-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page