Skip to main content

A MkDocs plugin that adds support for site-relative URLs

Project description

MkDocs Site URLs Plugin

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/bar/ /bar/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.

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.

License

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

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-site-urls-0.2.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

mkdocs_site_urls-0.2.0-py2.py3-none-any.whl (3.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file mkdocs-site-urls-0.2.0.tar.gz.

File metadata

  • Download URL: mkdocs-site-urls-0.2.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mkdocs-site-urls-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1a2a1363e55de0bb9818984ae544a6f2f48a851d0112ebe097ad392eeaaf1cec
MD5 77ac819bc194ef5a55d2a2e839a8b660
BLAKE2b-256 7a7a5b6eedc45546a0d015ef60e8bccdce217ac4d2b383aeb51a92f2ffdf1504

See more details on using hashes here.

File details

Details for the file mkdocs_site_urls-0.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_site_urls-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 675cdf9c3f759620edfb3011cc75226daf106593548c93ee568feb5ffd3cc089
MD5 4b1dce0fcff148d94ada671ecc37f142
BLAKE2b-256 edcc5687d30325573e9f00b2be28b11b81c6bd982807754e1e18cdb4c999e792

See more details on using hashes here.

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