Skip to main content

MkDocs Site URLs Plugin

GitHub release PyPI Build status Code of Conduct Code style: black Imports: isort pre-commit

A MkDocs plugin that adds support for site-relative site: URLs.

Example:

URL site_url resulting URL
site:images/foo.png https://example.com/ /images/foo.png
site:images/foo.png https://example.com/path/ /path/images/foo.png
site:images/foo.png unset/empty /images/foo.png

Please note: This plugin requires MkDocs 1.5 or higher.

Getting Started

  1. Install the plugin from PyPI
    pip install mkdocs-site-urls
    
  2. Add the site-urls plugin to your mkdocs.yml plugins section:
    plugins:
      - site-urls
    
  3. Start using site-relative URLs in your Markdown files by prefixing them with site::
    [Link to another page](site:another-page/relative/to/the/site/root)
    
    ![Image](site:images/foo.png)
    

Configuration

By default the plugin will replace URLs in href, src and data attributes. You can configure the attributes to replace by setting the attributes option in your mkdocs.yml, e.g.:

plugins:
  - site-urls:
      attributes:
        - href
        - src
        - data
        - data-url

Be advised that in case of any customization on your part you need to include the default attributes as well if you want to keep them, as the default list will not be included automatically anymore.

If site: as the prefix does not work for you for any reason, you can also configure that, e.g.

plugins:
  - site-urls:
      prefix: "relative:"

This can also be used to interpret absolute URLs like /example/file.png as relative, by setting the prefix to /.

The plugin will extract the path prefix to use from the site_url. configured in your mkdocs.yaml. If no site_url is configured, it will default to using the root path /.

How it works

The plugin hooks into the on_page_content event and replaces all URLs in the configured attributes (by default href, src or data) in the rendered HTML with the corresponding site-relative URLs.

Development

  1. Create a venv & activate it, e.g. python -m venv venv && source venv/bin/activate
  2. Install the dev requirements: pip install -r requirements-dev.txt
  3. Install the pre-commit hooks: pre-commit install

You can run the tests with pytest.

To build the docs, install their dependencies as well (pip install -r requirements-docs.txt), then run mkdocs build.

License

This project is licensed under the MIT license, see the LICENSE file for details.

Metadata

Release files for mkdocs-site-urls 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mkdocs-site-urls 0.3.1
File Size Uploaded Provenance
mkdocs_site_urls-0.3.1.tar.gz 5.9 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs-site-urls 0.3.1
File Interpreter ABI Platform
mkdocs_site_urls-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.3 kB

Release files / mkdocs_site_urls-0.3.1.tar.gz

Download URL mkdocs_site_urls-0.3.1.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6c39b4aca9d0d29d747513bb679f5cc4e5957e37895ea5a12589e139ed1af3a9
BLAKE2b-256 checksum
How to use checksums
3f9cd02d2e089b128e9d84c46fb757738ae56bffce33b5ad90dec4f280d03436
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2025.

Transparency log

Release files / mkdocs_site_urls-0.3.1-py3-none-any.whl

Download URL mkdocs_site_urls-0.3.1-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e13f606e3de0fe52bfa7c152940a32fb0445a4a0e452b0387062a2ffe70e1662
BLAKE2b-256 checksum
How to use checksums
c3d34e93e993e3558fe70dc6ecda0e65694389b523dcebfa267515958cf99984
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2025.

Transparency log

Security for mkdocs-site-urls 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mkdocs_site_urls-0.3.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page