Skip to main content

Mkdocs plugin to convert absolute paths to Webcontext aware paths.

Project description

Webcontext link converter plugin for mkdocs

MkDocs allows absulute paths assuming that the site is deployed to the root of the hosted website like "http://localhost/". When using the following absolute path "/assets/image1.jpg" it is actually using "http://localhost/assets/image1.jpg" which is correct if the MkDocs is deployed to the site root.

When the server root is not the same as the MkDocs root, the webcontext plugin can be used to define a webcontext to use instead of the defined root. The webcontext path which can be anyting like "/projectname/documents" is used where "/" is defined.

Some examples of site urls before and after using the webcontext plugin:

Site Url Context Image before Image after
http://example.com/ / /images/img1.jpg /images/img1.jpg
http://example.com/foo /foo /images/img1.jpg /foo/images/img1.jpg
http://example.com/foo/bar /foo/bar /images/img1.jpg /foo/bar/images/img1.jpg
http://127.0.0.1:8000 / /images/img1.jpg /images/img1.jpg
http://127.0.0.1:8000/foo /foo /images/img1.jpg /foo/images/img1.jpg

Quick start

  1. Install the module using pip: pip install mkdocs-webcontext

  2. In your project, add a plugin configuration to mkdocs.yml:

    plugins:
      - webcontext:
          context: foo/bar
    

Special thanks to the following repositories for guidance:

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-webcontext-plugin-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

mkdocs_webcontext_plugin-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs-webcontext-plugin-0.1.0.tar.gz.

File metadata

  • Download URL: mkdocs-webcontext-plugin-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.8

File hashes

Hashes for mkdocs-webcontext-plugin-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1f01bf27cebe46467bfb56866e54efbf15389ea0b3ded4a0bd2d356c9388c38c
MD5 f796f8b59a8555a5cfd9deaeefea419b
BLAKE2b-256 2eb43f22f3852f0764c5a744f28e726069f8ff8e0d03b1da7ab8c7a334f58655

See more details on using hashes here.

File details

Details for the file mkdocs_webcontext_plugin-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mkdocs_webcontext_plugin-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.8

File hashes

Hashes for mkdocs_webcontext_plugin-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 20244fc9b0a547c53f4dfc32a401626a4b9d7216845371bf5758226f62dd42b9
MD5 ee9f5ade353a0d2aff3e162b0b3299c7
BLAKE2b-256 80e53a2dd5bf3f8d17511dc46b45ee4d70c8efec6a04e3d6015dd05ce718e187

See more details on using hashes here.

Supported by

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