MkDocs plugin: rewrite ../ repo links to forge view URLs in built HTML
Project description
mkdocs-source-links
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.
- Files →
https://…/blob/<branch>/<path> - Directories →
https://…/tree/<branch>/<path> - v1: GitHub only (other hosts: links left unchanged)
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:
- search
- source-links
Optional branch override:
plugins:
- source-links:
branch: develop
Link conventions
| Target | Source markdown | Built HTML |
|---|---|---|
Page in docs/ |
[runbook](other.md) |
unchanged (MkDocs handles it) |
Repo file outside docs/ |
[config](../backend/config.py) |
forge blob URL |
| Repo directory | [scripts](../scripts/) |
forge tree URL |
Branch configuration
Branch for forge URLs is resolved in order:
- Plugin
branch:config extra.git_branchinmkdocs.yml- Parsed from
edit_uri(edit/<branch>/…orblob/<branch>/…) - Fallback:
main
If your default branch is not main, set edit_uri, extra.git_branch, or source-links.branch.
Not mkdocs-repo-docs
| mkdocs-source-links | mkdocs-repo-docs | |
|---|---|---|
| Approach | Rewrite outbound ../ links to the forge |
Stage repo markdown into docs/_repo/ |
| Source markdown | Keeps ../ paths |
Files copied into docs tree |
| Use case | Link to source from hand-written docs | Auto-publish scattered READMEs |
Development
uv sync --group dev
uv run pytest
uv run ruff check .
Publishing to PyPI
- Create a PyPI project
mkdocs-source-links - Configure Trusted Publishing for the
Publishworkflow (environment: pypi) - Tag a release:
git tag v0.1.0 && git push origin v0.1.0
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs_source_links-0.1.0.tar.gz.
File metadata
- Download URL: mkdocs_source_links-0.1.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
363952ff771f9ae2e81f727b613cea491e915385e999432726ff2c54ca6c56a3
|
|
| MD5 |
af5035aa4d0ec668093bf20f80e4d622
|
|
| BLAKE2b-256 |
0a8cff341f4b607ea9af2b00538b8900a33ae115d78ecdf5c8c96d0abc802f2b
|
Provenance
The following attestation bundles were made for mkdocs_source_links-0.1.0.tar.gz:
Publisher:
publish.yml on filipchristiansen/mkdocs-source-links
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocs_source_links-0.1.0.tar.gz -
Subject digest:
363952ff771f9ae2e81f727b613cea491e915385e999432726ff2c54ca6c56a3 - Sigstore transparency entry: 1839615192
- Sigstore integration time:
-
Permalink:
filipchristiansen/mkdocs-source-links@7746847405394bada73c09189631e346f1308e8f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/filipchristiansen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7746847405394bada73c09189631e346f1308e8f -
Trigger Event:
push
-
Statement type:
File details
Details for the file mkdocs_source_links-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mkdocs_source_links-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67ef76b4636803e56dbe1c4ecfc43b420dc9fa113699e436108d06ea73ba139d
|
|
| MD5 |
abb59f3128727a19a90eb663b2818bd5
|
|
| BLAKE2b-256 |
393bc29953ec5e4566bd02a1f87ac6258869e79e9c43f5e8a0d82c00135b612e
|
Provenance
The following attestation bundles were made for mkdocs_source_links-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on filipchristiansen/mkdocs-source-links
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkdocs_source_links-0.1.0-py3-none-any.whl -
Subject digest:
67ef76b4636803e56dbe1c4ecfc43b420dc9fa113699e436108d06ea73ba139d - Sigstore transparency entry: 1839615323
- Sigstore integration time:
-
Permalink:
filipchristiansen/mkdocs-source-links@7746847405394bada73c09189631e346f1308e8f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/filipchristiansen
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7746847405394bada73c09189631e346f1308e8f -
Trigger Event:
push
-
Statement type: