Today I learned #TIL: "How to make MkDocs support site_url relative URLs"

👉 https://foosel.net/til/how-to-make-mkdocs-support-siteurl-relative-urls/

#python #mkdocs

How to make MkDocs support site_url relative URLs

I’m currently finally back on converting the OctoPrint docs to using Markdown and MkDocs. Since I have some images in the docs that I want to be able to reference without having to use relative URLs (../../../../images/), especially since that would tie things in OctoPrint’s source tree structure too close to things in its documentation tree structure that might or might not end up being in a different repository in the future, I needed a way to use absolute URLs here (/images/).

I've now published this as a proper MkDocs plugin:

https://github.com/OctoPrint/mkdocs-site-urls

Note: Requires MkDocs 1.5 or newer.

GitHub - OctoPrint/mkdocs-site-urls: A MkDocs plugin that adds support for site-relative `site:` URLs.

A MkDocs plugin that adds support for site-relative `site:` URLs. - GitHub - OctoPrint/mkdocs-site-urls: A MkDocs plugin that adds support for site-relative `site:` URLs.

GitHub
@foosel that’s a neat solution! If I were still involved in the project I’d say that #MkDocs should have native support for something like this 😀

@d0ugal I agree, because that bothered me for ages now 😅

Not sure if there would be interest for a PR and frankly I have my hands full with other stuff too anyhow, so I opted for the plugin solution instead ^^

@foosel totally fair. I can relate with the lack of time. Nice work packaging it up tho’. Might be worth plugging the project on the issues you mentioned
@d0ugal Good point, started doing that this morning, forgot to continue ^^