Repository navigation
Say when mkdocs serve replaces site_url on a public address - #169
Merged
Merged
Conversation
mkdocs serve builds the site with its own address as site_url, so the canonical link becomes http://0.0.0.0:8000/... when it listens on 0.0.0.0. That is right for a preview, but people who host a site with mkdocs serve (for example in a container) get wrong canonical links (upstream mkdocs/mkdocs#4066). Keep the behavior, and when site_url is set and serve listens on a non-loopback address, log that pages link to the dev server instead of site_url and that mkdocs build is the way to publish. Document the same under site_url and dev_addr.
Contributor
This was referenced Nov 7, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mkdocs servebuilds the site with its own address assite_url, so with--dev-addr 0.0.0.0:8000the canonical link becomeshttp://0.0.0.0:8000/index.htmlinstead ofhttps://mydomain.de/index.html. That is intended for previews (absolute links must point at the page you are looking at), but people who host a site withmkdocs serve, for example in Kubernetes, end up with wrong canonical links and thinksite_urlis ignored.This keeps the behavior and makes it visible:
site_urlis set andservelistens on a non-loopback address, it logs one INFO line: pages use the dev-server URL instead ofsite_url, andmkdocs build+ a web server is the way to publish. INFO, so--strictis unaffected; loopback addresses and sites withoutsite_urlsee nothing new.site_urlanddev_addrdocs say the same.Related Issue
Upstream mkdocs/mkdocs#4066
Checklist
docs/about/release-notes.mdupdated (if applicable)