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
- Install the plugin from PyPI
pip install mkdocs-site-urls
- Add the
site-urlsplugin to yourmkdocs.ymlplugins section:plugins: - site-urls
- 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) 
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
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-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a2a1363e55de0bb9818984ae544a6f2f48a851d0112ebe097ad392eeaaf1cec
|
|
| MD5 |
77ac819bc194ef5a55d2a2e839a8b660
|
|
| BLAKE2b-256 |
7a7a5b6eedc45546a0d015ef60e8bccdce217ac4d2b383aeb51a92f2ffdf1504
|
File details
Details for the file mkdocs_site_urls-0.2.0-py2.py3-none-any.whl.
File metadata
- Download URL: mkdocs_site_urls-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
675cdf9c3f759620edfb3011cc75226daf106593548c93ee568feb5ffd3cc089
|
|
| MD5 |
4b1dce0fcff148d94ada671ecc37f142
|
|
| BLAKE2b-256 |
edcc5687d30325573e9f00b2be28b11b81c6bd982807754e1e18cdb4c999e792
|